Is your feature request related to a problem? Please describe.
Tried updating from 0.13.0 to 0.14.0.
There are no docs for introspection Pugin and how to provide auth header.
Had this npm script for introspection:
"gql-gen:introspect": "gql-gen --schema http://localhost:4000 --header \"Authorization:[key]\" --template graphql-codegen-introspection-template --out ./src/app/graphql/generated/gql-gen-schema.json"
CLI suggested following config:
schema:
- "http://localhost:4000"
documents: []
config: {}
generates:
./src/app/graphql/generated/gql-gen-schema.json:
config: {}
plugins:
- "introspection"
require: []
Describe the solution you'd like
Add Docs for Introspection Plugin option and Auth header yaml config syntax.
Describe alternatives you've considered
roll back to 0.13.0
Additional context
Also some frustration stitching together the new yaml config.
Before I had the above introspect script and this generate script:
"gql-gen:generate": "gql-gen --schema ./src/app/graphql/generated/gql-gen-schema.json --template graphql-codegen-apollo-angular-template --out ./src/app/graphql/generated/gql-types.ts src/app/graphql/graphql-queries/*.graphql"
Was trail and error to merge it into codegen.yml config:
schema:
- http://localhost:4000
# not sure about Auth header syntax here
- headers:
Authorization:
- "Bearer [key]"
generates:
./src/app/graphql/generated/gql-gen-schema.json:
plugins:
- "introspection"
generates:
./src/app/graphql/generated/gql-types.ts:
config:
noGraphqlTag: true
schema:
- ./src/app/graphql/generated/gql-gen-schema.json
documents: ./src/app/graphql/graphql-queries/*.graphql
plugins:
- typescript-common
- typescript-client
- typescript-apollo-angular
And not even sure if this is correct.
Congrats for launching docs and site looks great!
@qirex thank you for reporting it!
Actually, headers has moved to be an object under the url, so you should be able to do:
schema:
- "http://localhost:4000":
headers:
Authorization: "Bearer [key]"
generates:
./src/app/graphql/generated/gql-gen-schema.json:
plugins:
- "introspection"
I'm leaving this open because I know there are some things that are not documented yet, but we are working on it now!
Done in: https://github.com/dotansimha/graphql-code-generator/pull/874
Docs for URL schema available now in: https://graphql-code-generator.com/docs/getting-started/schema-field#url
Follow up to this (v0.14.1):
Not working:
schema:
- "http://localhost:4000":
headers:
Authorization: "Bearer [KEY]"
generates:
./src/app/graphql/generated/gql-gen-schema.json:
plugins:
- "introspection"
Output:
× Load schema
→ (schemaOptions.headers || []).map is not a funct…
Generate outputs
(schemaOptions.headers || []).map is not a function
~Working:~ See edit
schema:
- "http://localhost:4000":
headers:
Authorization: "Bearer [KEY]"
generates:
./src/app/graphql/generated/gql-gen-schema.json:
plugins:
- "introspection"
An error either in docs or implementation?
EDIT:
Second config does not seem to work (files are not updated).
But output is showing success
√ Parse configuration
√ Parse configuration
√ Load schema
√ Generate outputs
Thanks @qirex ! Re-opening until we'll fix the issue with headers as object.
Fixed in 0.14.2 🎉
Most helpful comment
Done in: https://github.com/dotansimha/graphql-code-generator/pull/874
Docs for URL schema available now in: https://graphql-code-generator.com/docs/getting-started/schema-field#url