I'm generating graphql using codegen with this config:
'http://localhost:8080/v1/graphql':
headers:
secret: "devsecret"
'http://localhost:3000/api/auth':
headers:
secret: "devsecret"
documents: './**/*.graphql'
overwrite: true
generates:
generated/graphql-sdk.ts:
config:
rawRequest: true
plugins:
- 'typescript'
- typescript-graphql-request
- 'typescript-operations'
- fragment-matcher:
apolloClientVersion: 3
module: es2015
useExplicitTyping: false
generated/graphql.ts:
config:
reactApolloVersion: 3
withHooks: true
withComponent: false
withHOC: false
skipTypename: true
plugins:
- 'typescript'
- 'typescript-operations'
- 'typescript-react-apollo'
- fragment-matcher:
apolloClientVersion: 3
module: es2015
useExplicitTyping: false
Some of the queries are server side and others are used client side.
I found out the generated JS bundle has references to the entire generated graphql file, including the query strings and types - which is obviously unecessary and causes slow downs on load. Lots of functions called things like 'function _templateObject[1, 2, 3, N...]' everywhere.
While everything in the generated graphql file is used in different parts of the webapp not all of it is used on one page and certainly the server side queries are not used by the frontend.
Is there a way to prevent the query types from being exported