.graphql_code_generator.js 1.8 KB

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