Codegen with 2 outputs: 1 succeeds, 1 fails but both not written to file
Describe the bug I have two outputs, one schema-ast, the other typescript types. both run in the same config, the schema completes with a green checkmark, the typescript fails (as expected, because of an intentional code error). But the schema is not written to file although it says it did.
As you can see, 2 outputs, one finishes with success, the other fails. but the successful output is not written to file either. It is important the schema outputs correctly even though the typescript output does not, because i use the schema for eslint/vscode-autocompletion to fix the error.
To Reproduce Just use 2 outputs have one fail the other succeed.
- My GraphQL schema:
# not relevant
- My GraphQL operations:
# not relevant
- My
codegen.ymlconfig file:
schema:
# Stitch all other microservices schemas into one
# We are being as specific as we can, not to watch hundreds of files, because then CPU goes 100%
- '../gqlgen/**/*.graphql'
# Define Apollo custom directives that eslint doesn't know about so we don't get errors
- './apolloFederationSpec.graphql'
overwrite: true
generates:
./schema.generated.graphql:
plugins:
- 'schema-ast'
config:
includeDirectives: true
./src/@generated/graphqlTypes.ts:
documents:
- './src/**/*.{ts,tsx}'
# Exclude the generated files, so we don't get duplications
- '!./src/@generated/**'
plugins:
- typescript
- typescript-operations
# for useQuery hooks:
- typescript-react-apollo
# for client-side mocks in apollo
- typescript-resolvers
# See: graphql-code-generator.com/docs/plugins/typescript-react-apollo#configuration
config:
# scalar => TS type mapping
scalars:
DateTime: number
JSON: string
withHOC: false
withHooks: true
withComponent: false
reactApolloVersion: 3
Expected behavior
Environment:
- OS: Mac OS 10.15.4
- NodeJS: 12.14.1 "@graphql-codegen/cli": "^1.13.3", "@graphql-codegen/introspection": "1.13.3", "@graphql-codegen/schema-ast": "^1.13.3", "@graphql-codegen/typescript": "1.13.3", "@graphql-codegen/typescript-operations": "1.13.3", "@graphql-codegen/typescript-react-apollo": "1.13.3", "@graphql-codegen/typescript-resolvers": "^1.13.3",
@kamilkisiela I think this is because we run everything in listr, and then do a single fs after it's done, right? maybe the fs write should be part of the listr flow?
I'm running into the same issue with a very comparable codegen file. The reason why I want the GraphQL json schema still written to the file system even when the other output fails is that I use vscode-graphql which uses the GraphQL json schema to show the errors from the other output file in vscode.
Hello, I have the same problem. Is there any way to solve this problem?
Hi @alSergey, could you provide a simple reproduction repo? And I help you!
@B2o5T hi ,I created a repository for you, where I described all the problems that I find while using code generation
@B2o5T hi, have you looked at the repository I sent you?
@alSergey, I do reproduce the issue which is linked to the current design of codegen. I'm moving this issue to our v3 roadmap so we can take a closer look and consider it.