Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fragments don't work with noGraphqlTag (apollo-angular) #831

Closed
mark-buer opened this issue Nov 12, 2018 · 4 comments
Closed

fragments don't work with noGraphqlTag (apollo-angular) #831

mark-buer opened this issue Nov 12, 2018 · 4 comments
Assignees
Labels
plugins waiting-for-release Fixed/resolved, and waiting for the next stable release

Comments

@mark-buer
Copy link

mark-buer commented Nov 12, 2018

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:

  • OS: macOS 10.13.6
  • Codegen: v0.13.0
  • Node: v10.11.0

Additional context
A recent comment on another issue makes me suspect that this issue is a known (but undocumented) limitation of the current implementation.

@kamilkisiela
Copy link
Collaborator

@mark-buer Could you share a small reproduction? Schema + document + fragment(s)?

@mark-buer
Copy link
Author

@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

@kamilkisiela
Copy link
Collaborator

I reproduced and fixed it in #852

@dotansimha dotansimha added the waiting-for-release Fixed/resolved, and waiting for the next stable release label Nov 16, 2018
@dotansimha
Copy link
Owner

Fixed in 0.14.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugins waiting-for-release Fixed/resolved, and waiting for the next stable release
Projects
None yet
Development

No branches or pull requests

3 participants