Questions tagged [graphql-codegen]

182 questions
1
vote
1 answer

How to use constant data instead of query field name?

In my React(Apollo client) App, for creating queries I am using gql`` tag from graphql-tag package, I am wandering if following is somehow possible to achieve: const bookField = 'books' const GET_BOOKS = gql` query getBooks { ${bookField} { …
Vano
  • 690
  • 3
  • 8
  • 25
1
vote
1 answer

GraohQL: how to create a query parameter constraint

How do I validate a GraphQL query parameter. I want the bookings query not to receive negative values on page parameter. I am using these modules for typescript types generation, is it possible to generate a constraint? (page > 0) { …
1
vote
1 answer

Duplicate "graphql" modules cannot be used at the same time

Good morning/afternoon stackoverflow. I'm using an npm package called @graphql-codegen/cli to generate type definitions/utilites for my GraphQL schema. Recently, I've been encountering an error each time I try to run graphql-codegen…
James McGuire
  • 48
  • 1
  • 8
1
vote
0 answers

GraphQL Code Gen - React Query Referenced Types

In our projects, we're generating our TS types using the react-query plugin which is super convenient when it comes to generating the required hooks (queries/mutations). However, we discovered that apollo:codegen is doing a much better job at…
Bassem
  • 3,582
  • 2
  • 24
  • 47
1
vote
0 answers

WpContentNode[] is not assignable to type WpPage[] error in Gatsby+WordPress+TypeScript project

This error occurs within a Gatsby + WordPress + TypeScript project component when pulling WordPress page data along with its child page data via GraphQL. Type 'WpContentNode[]' is not assignable to type 'WpPage[]'. On line: const pages: WpPage[] =…
Mission Mike
  • 393
  • 2
  • 11
1
vote
0 answers

Apollo withFilter doesn't notify client

Consider the following subscription for apollo: entityCreated: { subscribe: withFilter( () => pubsub.asyncIterator(["ENTITY_CREATED"]), async (payload, variables, context) => { let result = await…
Christo S. Christov
  • 2,268
  • 3
  • 32
  • 57
1
vote
1 answer

Remove custom directives from schema before loading

I am using graphql-codegen with typescript-mongodb plugin to generate database model files from the qraphql schema. And therefore my schema contains custom directive from the typescript-mongodb like @entity and @column. The codegen works fine but…
Dmitry Klochkov
  • 2,484
  • 24
  • 31
1
vote
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?
Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46
1
vote
1 answer

How do I handle non-null in Typescript when I don't request the item via GraphQL? - Typescript - GraphQL

I have a GraphQL (GQL) server and am using TypeScript (TS) on the front end. Here is my GQL type. type AutomatedAlgorithmValue { politicalEntityAlgorithmValueId: Long politicalEntityId: Long! ... } politicalEntityId is non-nullable. This…
jhamm
  • 24,124
  • 39
  • 105
  • 179
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 { …
1
vote
1 answer

Getting types generated similar to apollo codegen from graphql-codegen

I am new to apollo and graphql. I tried using both apollo-codegen and graphql-codegen and I want all the types generated in one single file like in graphql-codegen , but in apollo it creates multiple files. The issue I am having while using…
sudoDeznit
  • 108
  • 5
1
vote
2 answers

GraphQL CodeGen - perform same mutation an arbitrary number of times with a single request

I have defined a mutation which lets users duplicate their products, one product at a time: mutation DuplicateProduct($productID: ID!) { duplicateProduct(productID: $productID) { id } } Now I have to implement a feature, which would allow…
Avius
  • 5,504
  • 5
  • 20
  • 42
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{ …
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:…
0
votes
0 answers

Is there a way to avoid codegen List deletion when Optional type is used

I have this java's field : Optional> randomVar And when i run a codegen the Typescript's result is: InputMaybe How can I avoid the List deletion?