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

typedDocumentNode plugin: Usage with Apollo #376

Open
junwen-k opened this issue Aug 31, 2023 · 0 comments
Open

typedDocumentNode plugin: Usage with Apollo #376

junwen-k opened this issue Aug 31, 2023 · 0 comments

Comments

@junwen-k
Copy link

Issue

Projects that are using Apollo Client 3.0 onwards should use exports from @apollo/client instead of @graphql-typed-document-node/core and graphql-tag respectively.

When we pass in --td flag when generating, it outputs:

import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import gql from 'graphql-tag';
...

Proposal

Ideally, the CLI would be smart enough to detect if the project is using Apollo Client 3.x onwards (e.g, checking package.json for @apollo/client), and change the generated file to:

import { TypedDocumentNode, gql } from '@apollo/client';
...

Current Solution

I've manually changed the imports to use @apollo/client without installing additional packages.

Alternative Solution

If this is too many cases to be covered (E.g, to cover not only Apollo but other library as well), we could instead provide examples and let users to create this file themselves.

References:

Apollo 3.0.0: gql
Apollo 3.2.0: 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

1 participant