question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add prefix and namespacing when adding remote schema

See original GitHub issue

When 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:

  • OBJECT
  • INTERFACE
  • UNION
  • ENUM
  • INPUT_OBJECT

Important points to note:

  1. 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
  2. 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 __* and query_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:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:31 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
samuelcastrocommented, Apr 13, 2021

@tirumaraiselvan Do you have an idea when this will be implemented?

4reactions
dmovertoncommented, Jun 10, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespace Prefix in JavaScript and Apex within Installed ...
There are ways to surface the namespace itself from within Apex (doesn't help us in JavaScript, yet). Deriving the namespace prefix itself:
Read more >
Combining Schemas – GraphQL Tools
To include a remote schema in the combined gateway, you must provide at least the schema and executor subschema config options.
Read more >
Remote schemas | Front Commerce Developers
Root queries and mutations are prefixed with the GraphQL module namespace and an underscore. In the example above, the remote query pokemon(name: String!)...
Read more >
Namespace Prefix - an overview | ScienceDirect Topics
First, we declare the Schematron namespace as the default namespace, and a namespace prefix for our Jazz model. The latter is also defined...
Read more >
Defining a namespace prefix on a connection - Provar
Add a negative Namespace Prefix Override value and then a positive value in order to execute tests in an environment with a different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found