.graphql_code_generator.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @ts-check
  2. /** @type {import('@graphql-codegen/cli').CodegenConfig['generates'][string]} */
  3. const mockerPreset = {
  4. documents: ['app/frontend/**/{queries,mutations,subscriptions}/**/*.graphql'],
  5. preset: 'near-operation-file',
  6. presetConfig: {
  7. baseTypesPath: '~#shared/graphql/types.ts',
  8. importTypesNamespace: '',
  9. extension: '.mocks.ts',
  10. },
  11. plugins: ['./app/frontend/build/mocksGraphqlPlugin.js'],
  12. config: {
  13. importOperationTypesFrom: 'Types',
  14. skipDocumentsValidation: {
  15. skipValidationAgainstSchema: true,
  16. },
  17. },
  18. }
  19. /** @type {import('@graphql-codegen/cli').CodegenConfig} */
  20. const config = {
  21. overwrite: true,
  22. schema: 'app/graphql/graphql_introspection.json',
  23. config: {
  24. vueCompositionApiImportFrom: 'vue',
  25. addDocBlocks: false,
  26. },
  27. generates: {
  28. './app/frontend/shared/graphql/types.ts': {
  29. documents: [
  30. 'app/frontend/shared/**/*.graphql',
  31. 'app/frontend/apps/**/*.graphql',
  32. ],
  33. config: {
  34. scalars: {
  35. BinaryString: 'string',
  36. NonEmptyString: 'string',
  37. FormId: 'string',
  38. ISO8601Date: 'string',
  39. ISO8601DateTime: 'string',
  40. UriHttpString: 'string',
  41. },
  42. },
  43. plugins: ['typescript', 'typescript-operations'],
  44. },
  45. './app/frontend/': {
  46. documents: [
  47. 'app/frontend/shared/**/*.graphql',
  48. 'app/frontend/apps/**/*.graphql',
  49. ],
  50. preset: 'near-operation-file',
  51. presetConfig: {
  52. baseTypesPath: '~#shared/graphql/types.ts',
  53. importTypesNamespace: '',
  54. extension: '.api.ts',
  55. },
  56. plugins: ['typescript-vue-apollo'],
  57. config: {
  58. importOperationTypesFrom: 'Types',
  59. },
  60. },
  61. // generate mocks
  62. './app/frontend/apps/': mockerPreset,
  63. './app/frontend/shared/': mockerPreset,
  64. },
  65. }
  66. module.exports = config