Questions tagged [graphql-codegen]
182 questions
30
votes
5 answers
Unable to find any GraphQL type definitions for the following pointers: src/**/*.graphql
I am using the @graphql-codegen/cli tool to generate typescript types out of my graphql server.
Here is my codegen.yml content:
overwrite: true
schema: "http://localhost:3001/graphql"
documents: "src/**/*.graphql"
generates:
…

TheSoul
- 4,906
- 13
- 44
- 74
14
votes
8 answers
graphql-codegen not running with config file
In my package.json file I've got script entry that runs graphql-codegen but it complains that the --config argument is invalid:
$> yarn gen
yarn run v1.21.1
$ graphql-codegen --config codegen.yml
Error: Unknown argument: config
...
error Command…

aarona
- 35,986
- 41
- 138
- 186
11
votes
1 answer
How to resolve typescript error "Argument of type 'X' is not assignable to parameter of type 'Y'
UPDATE: Minimum example code reproduction
I have auto-generated code (Graphql-Codegen) that generates the following types. I've condensed it for simplicity.
export type AccessControlList = {
__typename?: 'AccessControlList';
id: Scalars['Int'];
…

Andre Marin
- 540
- 1
- 6
- 16
9
votes
3 answers
How to generate GraphQL operations from GraphQL schema
I am looking for a way to make the developer workflow more efficient while GraphQL.
Currently, using graphql-code-generator to generate types from my GraphQL server on the frontend.
This is great, but this is only generating types. In order to…

Dave
- 332
- 1
- 5
- 23
8
votes
1 answer
Generate sub types for graphql-codegen
I'm using the typescript-operations from graphql-codegen library. But I'm coming from the Apollo deprecated codegen and was loving how they exported types.
for a query like this
query MyData {
viewer {
id
username
}
}
I would get this…

Jeggy
- 1,474
- 1
- 19
- 35
8
votes
1 answer
How to map a custom scalar type to a typescript type when using graphql code generator?
A custom scalar type named Date which is an ISO 8601 string is defined in the backend.
In the frontend "GraphQL Code Generator" (https://www.graphql-code-generator.com/) is used to generate typescript types from the schema.
The codegen.yml looks…

David Berg
- 1,958
- 1
- 21
- 37
8
votes
1 answer
Vercel app with graphql-codegen endpoint error Unable to find any GraphQL type definitions for the following pointers
I load my GraphQL schema like:
const schema = loadSchemaSync('./src/graphql/server/schema/*.gql', {
loaders: [new GraphQLFileLoader()],
})
This works fine locally, however, when deploying to vercel I get the error:
Unable to find any GraphQL type…

neeko
- 1,930
- 8
- 44
- 67
8
votes
2 answers
Return incomplete shapes from resolver with GraphQL Code Generator
I use the following convention to let resolvers return partial data, and allow other resolvers complete the missing fields:
type UserExtra {
name: String!
}
type User {
id: ID!
email: String!
extra: UserExtra!
}
type Query {
user(id:…

Fez Vrasta
- 14,110
- 21
- 98
- 160
6
votes
2 answers
GraphQL Codegen duplicates RegisterDocument with typescript-urql
The codegen.ts config below results in duplicating the RegisterDocument entries.
codegen.ts:
const config: CodegenConfig = {
overwrite: true,
schema: "http://localhost:4000/graphql",
documents: "src/graphql/**/*.graphql",
generates: {
…

El Anonimo
- 1,759
- 3
- 24
- 38
6
votes
2 answers
GraphQL Code Generator - Failed to load schema from http://localhost:8000/graphql - Request with GET/HEAD method cannot have body
I've built a GraphQL API using strawberry and strawberry-django-plus that is hosted on http://localhost:8000/graphql using Django. I am able to successfully interact with the API using GraphiQL on the localhost page.
I'm now trying to access the…

sebtheiler
- 2,159
- 3
- 16
- 29
6
votes
4 answers
How to add headers to endpoints in RTK-Query Plugin?
Trying to follow the rather sparse tutorial on the official page doesn't get me far.
I'm essentially trying to add a certain header based on the params of an api call, but am clueless how to configure the endpoints to do so.

Bishonen_PL
- 1,400
- 4
- 18
- 31
6
votes
1 answer
What is the $condition input parameter for in a GraphQL mutation generated by AWS Amplify CLI?
I have generated a simple GraphQL API on AWS AppSync (using CLI) from this model:
type WalletProperty @model {
id: ID!
title: String!
}
This generated a CreateWalletProperty, UpdateWalletProperty and DeleteWalletProperty mutations all…

Lukas Rossa
- 367
- 4
- 16
6
votes
5 answers
GraphQL Code Generator - Cannot load my GQL Schema from Nestjs server endpoint
I'm using graphQL code generator on an angular app and I'm trying to load my schema from a local nestjs app.
Here is the codegen.yml file:
schema: http://localhost:3000/graphql
documents: ./src/app/graphql/**/*.graphql
generates:
…

AtActionPark
- 127
- 1
- 8
6
votes
3 answers
How to customize the type for a graphql-code-generator produced field when consuming a Hasura graphql schema
I would like to override a the jsonb type for a speficic field in a graphql schema produced by Hasura and run through graphql-code-generator.
I have a customList field of type jsonb. Ths is used to contain an array of json objects. When using…

arhnee
- 1,044
- 9
- 24
5
votes
3 answers
"The query argument is unknown error" for query types generated by graphql-codegen
I'm using Pothos to build a graphql schema and graphql-codegen to generate types based on this schema. The server runs via graphql-yoga and nextjs and the actual query works fine when run via the graphiql interface. I've been trying to set this up…

helion3
- 34,737
- 15
- 57
- 100