Questions tagged [graphql-codegen]
59 questions
1
vote
0 answers
Rename types with graphql-codegen
I'm working on a legacy codebase where, in our GraphQL schema, an interface was defined as 'Subscription':
interface Subscription {
fieldOne: String
fieldTwo: String
}
type FirstSubscriptionType implements Subscription {
…
![](../../users/profiles/5647450.webp)
kqcef
- 428
- 4
- 13
1
vote
1 answer
How to generate Typescript definitions from AppSync GraphQL schema if I am not using amplify?
I have my AppSync api set up using aws-cdk and am not using their amplify framework. I am trying to figure out how / if I can generate Typescript definitions from my AppSync schema.graphql file while not using amplify, i.e. no access to amplify…
![](../../users/profiles/911930.webp)
Ilja
- 35,872
- 66
- 218
- 401
1
vote
1 answer
Are array types incorrect when generating React/Apollo hooks with graphql-code-generator?
I am wondering if arrays defined in graphql queries/mutations, which can be either singletons or tuples in valid graphql implementation get converted to strict array types by graphql-codegen. Is this is by design ?
Given this schema:
schema {
…
![](../../users/profiles/4946637.webp)
Christian Hamelin
- 148
- 8
1
vote
1 answer
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:…
![](../../users/profiles/2059996.webp)
Fez Vrasta
- 11,462
- 19
- 73
- 135
1
vote
1 answer
typescript error: ' ' only refers to a type, but is being used as a namespace here
I went through several similar questions but wasn't able to get anywhere in solving this. I was following along with a tutorial from 2019 and I'm having trouble figuring out the right way to do the same thing in 2020. Here's the line I'm getting an…
![](../../users/profiles/14152645.webp)
mfsmusic
- 23
- 5
1
vote
0 answers
React modal container pattern with typescript and graphQL
Spectrum uses specific pattern for modals which I would like to replicate with typescript, graphQL and graphQL-codegen generated hooks.
Now what I currently have:
GraphQL Client Schema
enum ModalType {
LOGIN,
SIGNUP,
}
type LoginModalProps{
…
![](../../users/profiles/10900072.webp)
Honza Kirchner
- 11
- 1
1
vote
1 answer
Assigning a type to a property that is a nested type of a Maybe type
I'm trying to assign to a property a type generated by the graphql-codegen tool. The type I'm trying to assign is a nested type. Given the following type:
type SomeType = {
someKey: Maybe<
{ __typename?: "OtherType" | undefined } &
{…
![](../../users/profiles/905076.webp)
Lee
- 401
- 5
- 18
1
vote
1 answer
Apollo client for angular: code generation from graphql files
I came to know about angular graphql code generator from here. I am trying to use it in my project to generate the graphql types and Query services for angular.
My codegen.yml file looks like below.
overwrite: true
schema:…
![](../../users/profiles/1601336.webp)
Victor Mukherjee
- 9,389
- 15
- 46
- 83
0
votes
1 answer
how to run amplify codegen in where codegen is already configured?
we have a project repo where backend team have added new apis.
other developers have run and configured amplify and codegen.
now I want to add these new queries and their types.
when I run amplify codegen i get this error:
Please download the…
![](../../users/profiles/13966218.webp)
Mahmood Ahmed Khan
- 95
- 4
0
votes
0 answers
Using graphql-codegen enumValues with near-operation-file and typescript-react-apollo
Im using the following graphql-codegen config to generate typescript graphql code.
First output includes all type definitions and resolver types (typescript - typescript-resolvers)
Second output includes apollo hooks and operation types/codes which…
![](../../users/profiles/1016147.webp)
sercan
- 305
- 1
- 3
- 13
0
votes
0 answers
Property does not exist on type in GraphQL query result
In the React component I use a GraphQL query to fetch data:
const { data, error, loading } = useGetEmployeeQuery({
variables: { id: "a34c0d11-f51d-4a9b-ac7fd-bfb7cbffa" }
});
On the data destructure
const { first_name } =…
![](../../users/profiles/5524590.webp)
El Anonimo
- 1,073
- 1
- 13
- 27
0
votes
1 answer
How to generate Graphql types for React with help of graphql-codegen when Apollo Server is in production mode?
When backend mode set to NODE_ENV: development all works perfectly, but in production mode graphql-codegen fails with error:
Local web-server error:
GraphQL introspection is not allowed by Apollo Server, but the query
contained _schema or _type. To…
![](../../users/profiles/1876843.webp)
Eugene Zalivadnyi
- 152
- 11
0
votes
1 answer
Convert Maybe[]' to 'string[]
I am using graphql with generated types and struggling with how to convert them to the type I need to pass it to my data service calls.
@graphql-codegen has given me an args type of
export type QueryOrdersArgs = {
ids:…
![](../../users/profiles/10917982.webp)
tmc
- 178
- 2
- 12
0
votes
0 answers
How do I use graphql-code-generator with Hasura when they expect differently-named query roots?
The schemas emitted by Hasura group queries under a query_root type. But graphql-codegen expects them grouped under a type named Query. How do people bridge that gap?
![](../../users/profiles/1056174.webp)
Carl Patenaude Poulin
- 4,468
- 4
- 17
- 36
0
votes
0 answers
GraphQL Code Generation React Hooks + Typescript (graphql-codegen)
We currently use graphql-codegen to generate React Hooks to query our GraphQL server.
Given we currently have 2 endpoints, we do a Split like so:
const endpoints = ApolloLink.split(
operation => operation.getContext().serviceName ===…
![](../../users/profiles/276673.webp)
turtlepick
- 2,577
- 19
- 22