Using fragments in conjunction with the noGraphqlTag option results in a code generation error.
To Reproduce
Take any existing graphql document with fragments, and try running:
CODEGEN_NO_GRAPHQL_TAG=true gql-gen --template graphql-codegen-apollo-angular-template ...
The generator produces the rather cryptic error:
Syntax Error: Unexpected $
Expected behavior
I would expect to be able to use fragments and the noGraphqlTag option without error.
I personally care more about reducing the repetition in my source code, and care less about reducing the size of my compiled code, thus I don't expect the generator to do anything clever in an attempt to factor out the fragments in the generated code (but if it did it would be a bonus).
Environment:
Additional context
A recent comment on another issue makes me suspect that this issue is a known (but undocumented) limitation of the current implementation.
@mark-buer Could you share a small reproduction? Schema + document + fragment(s)?
@kamilkisiela Here is a simple reproduction case:
# schema.graphql
schema {
query: Query
}
type Query {
user: User
}
type User {
name: String!
email: String!
}
# client.graphql
query currentUser {
user {
...CommonUserProperties
}
}
fragment CommonUserProperties on User {
name
email
}
The following works (without noGraphqlTag):
gql-gen --skip-schema --schema ./schema.graphql --template graphql-codegen-apollo-angular-template --out ./types.ts ./client.graphql
whereas the following doesn't work (with noGraphqlTag):
CODEGEN_NO_GRAPHQL_TAG=true gql-gen --skip-schema --schema ./schema.graphql --template graphql-codegen-apollo-angular-template --out ./types.ts ./client.graphql
I reproduced and fixed it in #852
Fixed in 0.14.0 馃帀