Is it possible to send an authorization token with the generated services? What I would like to do is send user's authorization token with each request to the GraphQL server so that I can get back only the data which this user should see.
Hi @rogerg93
It has nothing to do with the codegen, it's related only to the runtime library you use in your client-side (apollo/relay/url, each one has a different way of implementing auth).
The codegen only generates types or code for you, and has nothing to do with authentication.
I'm trying to use my production schema in order to generate a local introspection schema for the Apollo introspection fragment matcher, but the graphql endpoint is protected by authentication. How can I send my authentication token, in a header, along with the generate command?
You can generate it using a script, then set it as an environmental variable. Then use this env variable to send to codegen as an Authorization header.
Or you can use codegen programatically to generate a token
https://graphql-code-generator.com/docs/getting-started/schema-field#url
Most helpful comment
You can generate it using a script, then set it as an environmental variable. Then use this env variable to send to codegen as an
Authorizationheader.Or you can use codegen programatically to generate a token
https://graphql-code-generator.com/docs/getting-started/schema-field#url