Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace resolution for graphql schema

If I want to create 2 different User types based on context, how can I achieve it in graphql without naming them differently? Does graphql support namespaces or that concept in any form that we can achieve the same behavior? Please advise.

like image 752
dilip280 Avatar asked Sep 08 '26 08:09

dilip280


1 Answers

From the spec:

All types within a GraphQL schema must have unique names. No two provided types may have the same name. No provided type may have a name which conflicts with any built in types (including Scalar and Introspection types).

There is no concept of "namespaces" in GraphQL. A schema has operations, types, fields, arguments and directives -- that's it.

There's nothing wrong with having a single domain model (i.e. User) that maps to multiple types in your schema (i.e. Viewer and Friend).

like image 85
Daniel Rearden Avatar answered Sep 10 '26 15:09

Daniel Rearden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!