question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overriding default scalars

See original GitHub issue

I have a custom resolver for GraphQL’s ID scalar, which sends strings to the client but resolves to integers for the server.

I have tried specifying a custom type inside gql-gen.json, however I still get string inside the generated types.

Is there a way to override the types for default scalars such as ID?

// gql-gen.json
{
  "generatorConfig": {
    "scalars": {
      "ID": "number"
    }
  }
}
# schema.graphql
type MyType {
    id: ID!
}
// types.ts
export interface MyType {
 id: string;
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Slessicommented, Aug 30, 2018

I can confirm that it works for me now with the alpha branch

1reaction
ardatancommented, Aug 28, 2018

Found an issue about CLI’s gql-gen.json handling. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding standard ID scalar - graphql - Stack Overflow
So have to parse uuid from string everywhere I use ID type. I wonder is it possible to override ID type with my...
Read more >
Custom scalar types in Apollo Kotlin - Apollo GraphQL Docs
To interact with custom scalars in your Apollo Kotlin app, ... you can also do this with a built-in scalar (such as ID...
Read more >
Scalars - Hot Chocolate - ChilliCream GraphQL Platform
String is for example automatically mapped to a StringType in the schema. We can override these mappings by explicitly specifying type bindings.
Read more >
Override scalar style for particular properties - Google Groups
override the default style on `DumperOptions` but that means all scalars use the literal style and I really only want to use it...
Read more >
Custom Scalars and Enums – GraphQL Tools
The GraphQL specification includes the following default scalar types: Int , Float , String , Boolean and ID . While this covers most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found