Skip to content

Throwing error when using Map #931

Answered by dariuszkuc
fregin asked this question in Q&A
Discussion options

You must be logged in to vote

One of the core principles of GraphQL is the strong type safety. When you use Map for storing arbitrary objects it breaks that core assumption - e.g. how will your clients know what are the types stored in the map or in your case how does the client knows what are accepted input parameters? In general, instead of arbitrary map of objects you should be able to model your schema to have more meaningful type.

Currently GraphQL spec does not support arbitrary Map type (see graphql/graphql-spec#101 for details) so unfortunately we won't be adding support for it to this library.


NOTE: You should be able to add support to a generic Map type to your schema using schema generator hook.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@fregin
Comment options

@dariuszkuc
Comment options

@fregin
Comment options

Answer selected by smyrick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #931 on November 06, 2020 15:38.