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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With