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

use TypedDocumentNode from graphql-js #68

Open
backbone87 opened this issue Feb 15, 2021 · 4 comments
Open

use TypedDocumentNode from graphql-js #68

backbone87 opened this issue Feb 15, 2021 · 4 comments

Comments

@backbone87
Copy link

TypedDocumentNode type landed in graphql-js a while ago: graphql/graphql-js#2749

since codegen (and probably some early adaptor lib authors) use this module as a source for the TypeDocumentNode type, we now end up with 2 interfaces. can this package reexport the interface from graphql-js? (and maybe deprecate this package)

@dotansimha
Copy link
Owner

Thank you @backbone87 for reporting this. You are right, this was introduced, but we can't change it at the moment in this package, since it will drop support for previous GraphQL versions for all libraries that are using it. I think, with time, we can gradually move it when v15/v16 becomes more popular.

@backbone87
Copy link
Author

hm, is there a way to dynamically check what graphql peer version is installed?

@dotansimha
Copy link
Owner

hm, is there a way to dynamically check what graphql peer version is installed?

At the moment, no. Btw, You should be able to modify the import path of the typed DocumentNode, but note that it's not the issue here, since changing it still requires all libraries that support it to adjust and use the one from graphql-js.

@oclyke
Copy link

oclyke commented Sep 1, 2022

Just chiming in that I am interested in the same. @dotansimha's comment on this PR was spot-on:

Also, graphql-js is used by many projects locally, and execute sometimes is being executed directly with an operation that has been declared locally.

I am using graphql-js to execute documents in my API tests - it would be a big benefit to get type features on the results.

To clarify: I am able to use the DocumentNode that is generated by graphql-codegen in the input - I suspect this is the "built-in" support that is referred to in the README - but the result object retains an unknown type so we can't benefit from type hinting.

I'm on graphql-js 16.6.0 and @graphql-codegen/typed-document-node 2.3.3 - so perhaps I just need to upgrade to core@v3.1.1 wait - my actual package versions are:

@graphql-codegen/cli: 2.12.0
@graphql-codegen/typescript: 2.7.3
@graphql-codegen/typescript-operations: 2.5.3
@graphql-codegen/typed-document-node: 2.3.3
graphql: 16.6.0

These are all the latest versions. It seems like the only issue remaining is that graphql won't use the TypedDocumentNode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants