graphql-zeus
graphql-zeus copied to clipboard
typedDocumentNode plugin: Usage with Apollo
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.