Add a type name for namespaces
kroeder opened this issue · 2 comments
The optimistic-response mechanism of apollo-client wants a __type for every queried type
This might be useful in general, e.g. for things like introspection queries
myNamespace: {
__type: 'Namespace',
myData: [...]
},
someOtherNamespace: {
__type: 'Namespace',
...
}
Typename 'Namespace' could also be 'WeaverNamespace', I'm not sure what would fit best.
Hi, I don't exactly get what you mean. You can query the __type
of any GraphQL object, this is guaranteed by the spec. graphql-weaver also makes sure this type is fetched correctly in the case of abstract types.
What you suggest is not possible, both namespaces need to have different types because they offer different fields. The Query
, Mutation
and Subscription
root types will carry on their name from the individual schemas, possibly with a type prefix if typePrefix
is specified in the endpoint config. Thus, the following config:
weaveSchemas({
endpoints: [
{url: '...', namespace: 'myNamespace', typePrefix: 'My'},
{url: '...', namespace: 'someOtherNamespace', typePrefix: 'SomeOther'}
]
});
results in something like this:
myNamespace: {
__type: 'MyQuery',
myData: [...]
},
someOtherNamespace: {
__type: 'SomeOtherQuery',
...
}
I misunderstood __type. thanks for the info!
Closed.