Questions tagged [graphql-codegen]
182 questions
0
votes
0 answers
Only allow client side and currently used queries to be delivered in the JS bundle?
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:…

meds
- 21,699
- 37
- 163
- 314
0
votes
1 answer
How to apply mappers only to the parent and not to the resolver's return type?
In our graphql server there are essentially two types that exist in parallel.
The resolver return type, generated by graphql-codegen
The custom type existing internally before returning
The custom types are the actual entities that exist within…

kemicofa ghost
- 16,349
- 8
- 82
- 131
0
votes
1 answer
Graphql-codegen nested fragment use inside a React component
The nested fragment regularUserResponseFragmentDocument
import { graphql } from '../../generated/graphql';
export const regularErrorFragmentDocument = graphql(`
fragment regularError on FieldError {
field
message
}
`);
export const…

El Anonimo
- 1,759
- 3
- 24
- 38
0
votes
1 answer
Access inner indexed type in TypeScript
I have a type that's generated by GraphQL codegen that looks like the following:
export type GetAudioQuery = { audioByPk?: { address: string, id: any, title?: string | null, subtitle?: string | null, audio_tags: Array<{ tagId: any }> } | null };
In…

randombits
- 47,058
- 76
- 251
- 433
0
votes
1 answer
How do I use generated code from @graphql-codegen to do a simple fetch of a single record?
https://www.the-guild.dev/graphql/codegen
I have run through the getting started guide and now I have a generated code file that was built from an existing deployed federated graph. In there I have:
export type Query = {
__typename?: 'Query';
…

jcollum
- 43,623
- 55
- 191
- 321
0
votes
1 answer
How to merge 2 graphql schemas on client, to auto-generate types?
I have a client that queries 2 endpoints. Now, how do I auto-generate types from 2 graphql schemas, when using 2 endpoints?
Scripts I used up until now (with standard 1 endpoint) uses Apollo codegen (source):
"schema": "npx apollo service:download…

justdvl
- 698
- 4
- 15
0
votes
1 answer
How to call a function that is in return of another function
I am trying to access a function called in return of another function, but when I access it normally I get the error:
TypeError: adminSdk.InsertGameAuthRefreshTokens is not a function
at insertGameAuthRefreshTokens…
0
votes
1 answer
How to build codegen types from typeDefs?
I am trying to use graphql-codegen to generate my Typescript types by pointing it at my GraphQL type definitions.
However, I appear to get the error:
Failed to load schema from code file "./src/typeDefs.ts": Syntax Error: Expected Name, found…

Stretch0
- 8,362
- 13
- 71
- 133
0
votes
1 answer
How to reflect field policy's read function return types in graphql-codegen?
Assume this type policy:
// TLDR enum field of User object is replaced with some class instance on read
const userTypePolicies = {
User: {
fields: {
status: {
read: (value: STATUS_ENUM) => new UserStatus(value),
},
},
…

tymzap
- 896
- 7
- 10
0
votes
1 answer
Codegen generates graphql schema with import in incorrect place
I am using the graphql code generator tool to generate graphql types and hooks, and for some reason it generates a schema.ts file where the following import is placed all the way down on line 197 rather than at the top:
import { IntrospectionQuery }…

user8758206
- 2,106
- 4
- 22
- 45
0
votes
1 answer
How do I implement GraphQL resolvers in Typescript with Graphql-codegen?
In an effort to teach myself Apollo Server I was implementing the schema described here. CodeGen generated what look like very sensible definitions for the types.
export type Book = {
__typename?: 'Book';
author: Author;
title:…

Michael Lorton
- 43,060
- 26
- 103
- 144
0
votes
1 answer
How to change destination path for amplify codegen models in Flutter
I follow the tutorial and managed to properly generate models. I wonder how I can choose the destination where models are generated. By default it is lib/models.
How can I change the destination and split generated files between different folders?

Chris
- 839
- 1
- 12
- 30
0
votes
1 answer
How to debug @graphql-codegen/cli
Having difficult understanding where these errors are coming from. Adding --verbose and --debug to the command do nothing. I just want to know specifically what is causing the schema to fail to load. No matter what url I provide, it always fails.…

Nicole Staline
- 557
- 4
- 15
0
votes
1 answer
Does GQL support spreading / composing objects (eg. input args)?
I did not find anything about it in the Docs, but for me it seems to be a very common task, so is there a possibility/syntax or a workaround to achieve the following?
My GraphQL query looks something like this:
query customerPersons(
$pagination:…

ILCAI
- 1,164
- 2
- 15
- 35
0
votes
1 answer
Query on page not refetching once navigating back to page
In my nextjs page I have the following hook (generated by using graphql-codegen) that fetches a graphql query.
const { data, error, loading, fetchMore, refetch, variables } = useGetShortlistQuery({
notifyOnNetworkStatusChange: true, // updates…

mcclosa
- 943
- 7
- 29
- 59