apollographql / apollographql/apollo-tooling
Comment string in fragments results in no fragments found
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
I write a `Fragments.graphql` file with a comment in it, like:
```graphql
"""Extract just the id"""
fragment Foo on Bar {
id
}
```
and generate code for it.
**Actual outcome:**
I get the error `Unknown fragment "Foo"`. Additionally, if there were other errors in my fragment (e.g., `Field "..." of type "..." must have a selection of subfields`, they are hidden.
**How to reproduce the issue:**
Add a comment to a `.graphql` file containing fragments, attempt to use those fragments in other `.graphql` files during generation, see error.
I have a sample repo [here](https://github.com/sashaweiss/apollo-fragment-example) that demos this issue - `./bin/generate.sh` produces the error!
**Versions**
`apollo --version`: `apollo/2.21.2 darwin-x64 node-v13.1.0`
Thank you in advance for your attention! For the moment, I'm excluding comments from my fragments, and that should help. I'm also seeing some other strange fragment-related error behavior when I have many fragments in one file and there is a malformed one, but am still trying to narrow down a repro case (and as a workaround can make separate files for them - clunky but effective). Will follow up here or in a new issue if I can nail that down.
Contributor guide
Research direction
Use the linked sample repository to reproduce the problem, starting with ./bin/generate.sh and the .graphql file containing the commented fragment. Compare generation with and without the comment, including the additional malformed-fragment errors described. Done means commented fragments are discovered during generation and the relevant validation errors are no longer hidden.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100