Questions tagged [graphql-codegen]

182 questions
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…
0
votes
2 answers

Graphql codegen configuration does not load documents with Glob Expression

My API is written with TypeScript/Apollo and I am able to run queries/mutations on http://localhost:4000/graphql. My front-end is with Next.js and Apollo client. I use GraphQL Codegenerator to generate the client-side code I need. I am…
GGrassiant
  • 119
  • 4
  • 9
0
votes
1 answer

How should types like `Country = "United States" | "Canada" | ...` be represented in GraphQL?

Using https://graphql-code-generator.com/, the type in GraphQL is just set to String, but in my client code with the dropdown input, the type is more specific because it is derived from the dropdown options themselves: export const CODE_NAME_MAP =…
Garrett
  • 11,451
  • 19
  • 85
  • 126
0
votes
1 answer

How to use sequelize-typescript for querying relative objects through custom Apollo GraphQL resolver?

How to use sequelize-typescript for querying relative objects through custom Apollo GraphQL type? I have the following query without typescript: User and Event GraphQL types: type User { id: Int login: String email: String role:…
0
votes
0 answers

How to pass additional variables with Apollo Client 3?

I'm trying to pass additional variables in my client (apollo 3) like this: MY_QUERY = gql` mutation MyMutation { my_mutation { id name } } ` client.query({ query: MY_QUERY, variables: { extra_variable: 1, …
Marlos
  • 11
  • 2
0
votes
0 answers

Graphql Code Generator typescript operations plugin generates wrong types

I am using the graphql code generator with the typescript operations plugin to generate typescript types from my GraphQL schema. Everything was working fine until all of a sudden, when i run graphql-codegen --config codegen.yml the types generated…
Panos JC
  • 1
  • 1
  • 3
0
votes
1 answer

Named export multiple graphql operation from .gql files

I have some operations (query/mutation, and sometimes some fragments at the bottom of the file) defined in .gql files, sometimes more than one in a single file. I would like to import these into my JS/TS files, possibly also generate corresponding…
Balázs Orbán
  • 559
  • 1
  • 4
  • 26
0
votes
0 answers

Sequelize, Typescript and GraphQL: resolvers first argument type

I am a bit stuck in developing my GraphQL Api Server, using Sequelize and Typescript. My problem is related to a typing and concept issue. I have defined my Sequelize models according to the db tables and their relationships. I am using these models…
delca85
  • 1,176
  • 2
  • 10
  • 17
0
votes
0 answers

Graphql mutation throwing invalid value error

I'm trying to make a mutation request to my graphql api but I'm getting an invalid value error. I'm using graphql codegen with typescript and react on my front end. I directly copied my working graphql mutation that I created on graphql playground.…
0
votes
1 answer

How to type an Apollo useQuery hook generically?

So here's the wrapping component where I'm passing in a useQuery hook useOrganizationAutocompleteQuery generated by graphql-codegen. I'd like to be able to pass in any kind of useQuery hook.
blakesters
  • 81
  • 2
  • 10
0
votes
1 answer

Type alias from property that might be null with strictNullChecks

I am using graphql-codegen/typescript-apollo-angular to generate typescript code can be useed in our Angular application. We decided to enable strictNullChecks the only issue is that we use the following pattern to specify the types of inner nodes…
Jonas Osburg
  • 1,733
  • 1
  • 14
  • 17
0
votes
0 answers

graphql-codegen problem with generating typescript interfaces from graphql interfaces

I'm having a problem while generating TS interfaces from my graphQL schema. My code: export const userTypeDefs = gql` input SignUpRequestInput { name: String! password: String! role: Int! } interface SomeInter { name:…
0
votes
1 answer

Invalid hook calls when calling a graphql-codegen query with typescript + generated core used as a package

I'm using Yarn workspaces with a npm package having the generated code and a mobile package that uses it. When trying to make a call from an imported query I get an invalid hook call. Using any other hook in that component (i.e. useState) works…
0
votes
1 answer

Why these types are incompatible?

I have a Value type like this: export type Value = { __typename?: 'Value', key?: Maybe, label?: Maybe, value?: Maybe, }; And a query result type (generated apollo hooks) like…
platinum_ar
  • 127
  • 3
  • 8
0
votes
1 answer

Execute operations directly via apollo-codegen without naming them

I'm using graphql-codegen with apollo to consume graphql api from typescript. Right now I have to duplicate a lot of graphql operations exactly 1:1 to have some code generated. Example: mutation CreateAccount($name: String!, $email: String!,…
Krever
  • 1,371
  • 1
  • 13
  • 32
1 2 3
12
13