add prefix and namespacing when adding remote schema
See original GitHub issueWhen adding a data source (v1.4+), the user should be able to give a prefix which is added to every type and root fields. This will allow adding sources which have same table names (i.e. have conflicting names), etc. The user should also be able to give a namespace so that the graph of the data source appears under that namespace field in root types.
The prefix/namespace ability should be available for remote schema (graphql data source) as well.
Type Prefixing
The types that need prefixing are:
OBJECTINTERFACEUNIONENUMINPUT_OBJECT
Important points to note:
- Scalar types should be skipped from prefixing as same named scalars are “mergeable”. UPDATE: See https://github.com/hasura/graphql-engine/issues/5863#issuecomment-700742259
- Enum values should be skipped from prefixing.
Root fields i.e. fields under root types: query_root, mutation_root and subscription_root (or as defined by SCHEMA type) should also get the prefix. But non-root fields should not get any prefix.
Field Namespacing
When adding a source a namespace field can be given. If a namespace is given, then the fields of the source are added under that namespace respectively i.e. an object field with name <namespace> is added inside query_root, mutation_root and subscription_root and all the fields of the data source are added inside this object field.
For e.g., if the namespace is userservice:
query {
userservice {
getUser
}
mutation {
userservice {
deleteUser
}
Roadmap
Set of milestones for delivery.
POC
Current work in progress demonstrates the following:
- Optional prefix can be passed in on API calls to add a remote schema
- All types from the remote schema are prefixed except for
__*andquery_root,mutation_root,subscription_root.
The current branch (jberryman/5863-prep-refactoring-2) (as of 23/3/2021) is out of date with main and is being updated.
MVP
Additional features and changes:
- Default, per-source, and per-type naming configuration supported
- Tests for new functionality
- A new configuration format as described by Vamshi to be consumed by APIs and stored in metadata:
customization:
# if root_fields_namespace is absent, the fields
# are merged into the query root directly
root_fields_namespace: "something"
type_names:
prefix: some_prefix
suffix: some_suffix
# mapping takes precedence over prefix and suffix
mapping:
old_name: new_name
field_names:
old_type_name:
prefix: some_prefix
suffix: some_suffix
# mapping takes precedence over prefix and suffix
mapping:
old_name: new_name
V1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:31 (8 by maintainers)

Top Related StackOverflow Question
@tirumaraiselvan Do you have an idea when this will be implemented?
PR for remote schema customization (https://github.com/hasura/graphql-engine-mono/pull/974) has been merged. There is a new issue for type name customization for database sources: https://github.com/hasura/graphql-engine/issues/6974.