Le garcon
Le garcon

Reputation: 8427

Is it possible to overwrite scalar types in GraphQL?

I want an ID scalar to serialize data not as a string but rather as a Mongo Object id. The default behaviour is serializing data as a string. I don't want to create a custom scalar with another name as it may create some difficulties down the road.

Upvotes: 0

Views: 369

Answers (1)

David Maze
David Maze

Reputation: 160013

The ID type is required to serialize as a string, but absolutely nothing is specified about its format and it's intended to be opaque. You could use a Mongo object ID hex string as a GraphQL ID and (at a GraphQL level) there wouldn't be any problems with this.

Upvotes: 1

Related Questions