Feature Proposal: Allow namespacing of GraphQL queries #1130
Replies: 2 comments
|
Thanks for the great writeup, @aidanhollinshead-toast! This is a well-motivated feature request and I agree it's a worthwhile feature for supergraph use cases. I also think we can leverage it internally to remove some current special casing that's in place for the I've been thinking about how to support this. Rather than a Proposed Design1. Define a namespace type (new API)schema.namespace_type "OlapQuery" do |t|
t.documentation "Namespace for OLAP query fields."
end
2. Add it to the root Query type (existing API)schema.on_root_query_type do |t|
t.field "olap", "OlapQuery" do |f|
f.documentation "Namespace for OLAP query fields."
end
end
3. Target it from
|
|
Closing as this has been implemented. It'll be in the next release. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
When adding Elasticgraph to a supergraph it would be useful if the queries could all be namespaced, as opposed to always being under the top level
Query.Context
Currently, all generated queries are put at the root
Querylevel. This works okay for people connecting directly to Elasticgraph's GraphQL endpoint, but if you want to add Elasticgraph as a sub-graph in a corporate supergraph the EG queries can get lost amidst all the others.The Elasticgraph queries all have consistent query patterns, type names, etc. so we would like to be able to group them together. We would like to be able to put all the ElasticGraph queries into a namespace, for example
olap.Current State
Currently all generated queries get put in the root
Querydirectly. There is the ability to specify the plural and singular names in the root querywhich will then result in a schema of
Proposed Solution
Add an extra parameter to
t_root_query_fieldsthat will allow you to specify a namespace at the type level. For exampleThis would then result in the following GraphQL schema.
Having it on each
object_typegives maximum flexibility to use different namespaces on different objects.An alternative would be to have a
query_namespacethat you could wrap theobject_typeinwhich would produce the same GraphQL schema
All reactions