Questions tagged [graphql-codegen]
182 questions
1
vote
2 answers
How to add custom scalars to GraphQL Codegen?
I have a custom scalar in my GraphQL schema and I want my Codegen to generate the correct type fo me.
My schema looks like this:
scalar Decimal
type Item {
price: Decimal!
}
and I have added a custom resolver for this scalar which uses…

Stretch0
- 8,362
- 13
- 71
- 133
1
vote
2 answers
how to use `useQueries` hook (@tanstack/react-query) with graphql-codegen?
I've been using graphql-codegen for several month, it's a great tool.
I've always used it with @tanstack/react-query useQuery & useMutation hooks.
Today, I would like to use it with useQueries (documentation).
To give you more inputs, I'm receiving…

LIIT
- 496
- 6
- 16
1
vote
1 answer
Is it possible to codegen and consolidate all graphql queries and mutations for frontend and backend into a single file from .graphql and gql?
I'm using the @graphql-codegen/cli where my confirguration is set to output to a graphql and graphql-sdk file:
'http://localhost:8080/v1/graphql':
headers:
secret: "devsecret"
'http://localhost:3000/api/auth':
headers:
…

meds
- 21,699
- 37
- 163
- 314
1
vote
1 answer
How do I see GraphQL Code Generator cli's output?
I am using this https://github.com/dotansimha/graphql-code-generator for GraphQL code generation. The cli output is as below. Something is wrong with the "Generate outputs" because I am getting duplicate entities when generating the code, but since…

Bishal Heuju
- 13
- 6
1
vote
1 answer
Graphql Codegen specifying optional fields
Say I have the following fragment:
fragment ConversationSnippet on Conversation {
uuid
unreadMessages
profileThatHasUnreadMessages
updatedAt
createdAt
profiles{
...ConversationProfileSnippet
}
messages{
…

Frisbetarian-Support Palestine
- 1,277
- 1
- 12
- 27
1
vote
1 answer
Graphql Codegen: Issues generating hooks with types
I am using graphql codegen programmatically.
import * as typescriptReactApolloPlugin from "@graphql-codegen/typescript-react-apollo";
const config: Types.GenerateOptions = {
documents: [{ document: doc }],
config: {},
// returns the string…

dknaack
- 60,192
- 27
- 155
- 202
1
vote
0 answers
GraphQL with Prisma: how to make a delete mutation
I am trying to figure out how to make a delete mutation in my app.
I have an Issue Service, Issue Resolver, and Issue Form.
The service has:
import { prisma } from "../../lib/prisma"
import { Service } from "typedi"
import { IssueInput } from…

Mel
- 2,481
- 26
- 113
- 273
1
vote
0 answers
Graphql: Module '"lib/graphql"' has no exported member 'useAllCCIssuesQuery'
I am trying to learn how to use GraphQl.
I have created a query in my service and related resolver. I have run prisma generate on the back end and get no errors.
I cannot find a way to update the lib/graphql so that it includes the query I have…

Mel
- 2,481
- 26
- 113
- 273
1
vote
0 answers
RefetchQueries does not invalidate cached data for unmounted components in Apollo
Backdrop: I'm developing a React application using Apollo to query a GraphQL backend, a standard InMemoryCache and GraphQL codegen to generate typescript hooks for queries and mutations.
In some cases I am using refetchQueries to make sure cache is…

Knut Marius
- 1,588
- 18
- 40
1
vote
1 answer
Using code-gen in production when introspection is disabled
I have a nextjs & typescript & apollo-client app that communicates with a GraphQL API and it uses code-gen to generate types using the introspection in development environment. It works well in dev so no questions here.
In production we have…

kakakakakakakk
- 467
- 10
- 31
1
vote
1 answer
Error "Object is of type unknown" when using graphql-codegen in the Angular application
I have this Angular application which enjoys graphql-codegen to generate model for the application through graphql end point.
the component includes an image tag inside a container:

amin mohammadi
- 901
- 2
- 15
- 33
1
vote
1 answer
GraphQL Code Generator: Decorate URL with query string
I am using graphql-codegen yarn package to generate React hooks
graphql-codegen --config codegen.yml
I want to decorate every GraphQL endpoint call with an operation name, so I could see the operation name in the DevTools console:
I have tried to…

TURNSKIN
- 35
- 1
- 7
1
vote
0 answers
How to auto-generate Angular model.ts (interface) based on graphql schema?
I want to auto-generate Angular/Typescript model.ts (interface) from graphql schema.
Added "@graphql-codegen/typescript-apollo-angular": "3.4.12", in package.json
In codegen.yaml
/src/models/model.ts:
plugins:
-…

Gnik
- 7,120
- 20
- 79
- 129
1
vote
0 answers
typescript generic type function to get the name of a given type
I'm using graphql-codegen to generate types for my graphql server and also using the same schema to generate types for my DB(which is not exactly the same) using mongo plugin for codegen
I've configured codegen to generate to each type with the name…

Eliav Louski
- 3,593
- 2
- 28
- 52
1
vote
1 answer
GraphQL Codegen with AWS AppSync Annotations
I've got a graphql schema with added AppSync annotations like:
@aws_oidc @aws_api_key
One type looks like that for example:
type Response @aws_oidc @aws_api_key {
id: ID!
body: AWSJSON!
status: Int!
header: AWSJSON!
url: String!
…

Sandro_V
- 477
- 1
- 7
- 21