Is your feature request related to a problem? Please describe.
It seems that detection of graphql tags in gatsby projects is not working, so my queries are not getting types created. If I make a separate .graphql file for my queries, then I see generated types, but it seems that gatsby doesn't allow keeping queries in separate files.
Describe the solution you'd like
It seems like there's an option for gqlPackName in graphql-tag-pluck. I believe I need to set this, because my file looks like:
import {StaticQuery, graphql} from 'gatsby';
Instead of gql or graphql coming from graphql-tag.
Describe alternatives you've considered
I'm not sure how else to get this working, but would love to hear!
Additional context
I actually went digging for the usage of graphql-tag-pluck within this package in my node_modules, and I can't find it. It seems like it continues to be updated with new versions, but searching this repo, I can't find where it's used. Maybe it got taken back out at some time?
It looks like usage of graphql-tag-pluck was removed in https://github.com/dotansimha/graphql-code-generator/commit/eb9d6ff39290d3c8e852a8375d1338bdeca4957d, although the dependency was not.
I've found that in version 0.16.0, I can change this line: https://github.com/dotansimha/graphql-code-generator/blob/325baef0a08a3a80536121326bbdf634379a3262/packages/graphql-codegen-cli/src/utils/document-finder.ts#L14
to:
return gqlPluck.fromFile.sync(source.name, {gqlPackName: 'gatsby'}) || null;
AND:
from:
const gqlImportSpecifier = path.node.specifiers.find((importSpecifier) => {
return t.isImportDefaultSpecifier(importSpecifier)
})
to:
var gqlImportSpecifier = path.node.specifiers[0];
Then I can get types generated from my source gatsby files. Is there any way to accomplish the same thing without hacking on these files? I'm not sure what's being used now that graphql-tag-pluck was removed, but I'm guessing it's not as flexible. If so, am I just out of luck with using this in gatsby?
DAB0mB/graphql-tag-pluck#12 should handle that
That's awesome, thanks! Would graphql-tag-pluck need to be re-added to graphql-code-generator as well? Or is it still being used in a way that I couldn't figure out?
We moved some logic to graphql-toolkit package and graphql-tag-pluck is a part of that.
Fixed in 0.18.0 馃帀
Most helpful comment
Fixed in https://github.com/dotansimha/graphql-code-generator/pull/1364