You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to build an application backed by mongodb that allows users to create namespaces (backed by mongo collections) and write configurations (backed by mongo documents) under these namespaces. When a client creates a namespace they specify a jsonschema describing the schema(s) that the configuration documents stored within the namespace can have. For example, consider a namespace schema specification like this:
Configuration documents written to this namespace would have to have a schema structure matching at least one of the object specifications above. This is enforced by using the Schema Validation feature of mongodb.
I'd also like to be able to query these configuration structures using GraphQL. Clients should be able to fetch properties of configuration documents within a namespace matching their GraphQL query. For example:
the query above would fetch all of the configuration documents that have a hairColor field and return the hairColor properties for that field.
Another example:
query {
configurations(namespaceId: "mynamespace") {
hairColor
name
}
}
the query above would fetch all of the configuration documents that have a name and a hairColor field and return the hairColor and name fields from them.
When a new namespace is added to the system I'd like to generate a GraphQL schema from the namespace's schema specification and register it at runtime with the GraphQL server so that I can serve queries for configuration documents stored with these namespaces. Any two namespaces might have completely different schemas governing the structure of the configuration documents in that namespace.
Is something like this supported? If so, how do I go about doing that? If not, does the gqlgen community have any suggestions for designing something like this?
This discussion was converted from issue #1691 on February 04, 2022 00:43.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to build an application backed by mongodb that allows users to create namespaces (backed by mongo collections) and write configurations (backed by mongo documents) under these namespaces. When a client creates a namespace they specify a jsonschema describing the schema(s) that the configuration documents stored within the namespace can have. For example, consider a namespace schema specification like this:
Configuration documents written to this namespace would have to have a schema structure matching at least one of the object specifications above. This is enforced by using the Schema Validation feature of mongodb.
I'd also like to be able to query these configuration structures using GraphQL. Clients should be able to fetch properties of configuration documents within a namespace matching their GraphQL query. For example:
the query above would fetch all of the configuration documents that have a hairColor field and return the hairColor properties for that field.
Another example:
the query above would fetch all of the configuration documents that have a name and a hairColor field and return the hairColor and name fields from them.
When a new namespace is added to the system I'd like to generate a GraphQL schema from the namespace's schema specification and register it at runtime with the GraphQL server so that I can serve queries for configuration documents stored with these namespaces. Any two namespaces might have completely different schemas governing the structure of the configuration documents in that namespace.
Is something like this supported? If so, how do I go about doing that? If not, does the gqlgen community have any suggestions for designing something like this?
I'm looking for something similar to DGS's Dynamic schemas support.
Beta Was this translation helpful? Give feedback.
All reactions