When backend mode set to NODE_ENV: development
all works perfectly, but in production mode graphql-codegen fails with error:
Local web-server error:
GraphQL introspection is not allowed by Apollo Server, but the query contained _schema or _type. To enable introspection, pass introspection: true to ApolloServer in production
Production web-server error:
Failed to load schema from https://example.com/graphql, reason: unable to verify the first certificate. GraphQL Code Generator supports:
- ES Modules and CommonJS exports (export as default or named export "schema")
- Introspection JSON File
- URL of GraphQL endpoint
- Multiple files with type definitions (glob expressions)
- String in config file
Front-end codegen.yml:
schema: ${REACT_APP_GRAPHQL_URL}
documents:
- './src/GraphQL/queries/query.ts'
- './src/GraphQL/mutations/mutation.ts'
overwrite: true
generates:
./src/generated/graphql.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
config:
skipTypename: false
withHooks: true
withHOC: false
withComponent: false
Front-end devDependencies:
{
"@graphql-codegen/cli": "^1.20.1",
"@graphql-codegen/typescript": "^1.20.2",
"@graphql-codegen/typescript-operations": "^1.17.14",
"@graphql-codegen/typescript-react-apollo": "^2.2.1",
}
npm scripts:
{
"generate": "graphql-codegen -r dotenv/config --watch --config codegen.yml",
"prebuild": "graphql-codegen -r dotenv/config --config codegen.yml"
}
./src/generated/ directory added to .gitignore