GraphQL :type, prefix based on Context?
In the example docs, we have something like the following:
So, the following introspection query would return
Ticket
as a type.
So, given a totally made up hypothetical, if we had another Ash API with a resource Amusement.Parks.Ticket
, included in the same Ash GraphQL Schema... wouldn't the two Ticket
graphql names clobber each other?
So, is there a way to automatically prefix the resource with a context/api based name? To get graphql like HelpdeskSupportTicket
and AmusementParksTicket
?
Or is it up to the application developer to explicitly define type :helpdesk_support_ticket
and type :amusement_parks_ticket
?3 Replies
You could write an extension that would do that, yes
I probably wouldn't suggest it though, TBH
You'll get a compile time error about duplicate types
so you can use that to see that you've created a conflict
But it is possible yes to write an extension that prefixes a resource's graphql type with some configured value based on the api you use it with, that kind of thing
Ok. To recap what I think you're saying is that
1. Just having
type :ticket
w/o extension will result in compile time error
2. That, it is possible to write extension to both prefix the GraphQL type (in GraphQL schema) and to avoid a compile time problem with multiple type :ticket
3. That you suggest against writing an extension, and that just manually prefixing (e.g. type :helpdesk_support_ticket
) is the easier/safer bet.
Did I understand correctly? If so, thanks! 👍yes 👍