How do I convert a DocumentNode graphql document to a query string? while still respecting apollo features like the client directive.
I can do this directly with graphql
import { print } from 'graphql';
const query = gql`
query todos {
todoCollection {
id
name
color @client
}
}
`
const queryAsString = print(query);
However the apollo client does some “magic” like adding __typename
and stripping out @client
directives, to the query. Are there any way I can take the gql document node and get a query string that matches what apollo client would do?