Skip to main content
Version: v2.x

Namespacing Remote Schemas

Introduction

When integrating multiple schemas into your Hasura project, there may be instances where two schemas define types with the same name. This can lead to naming conflicts, preventing your GraphQL schema from working correctly.

To solve this, you can use namespacing and prefixes to ensure that each type definition has a unique identifier.

Common Error: Conflicting Definitions

Hasura GraphQL Engine automatically checks for type conflicts in your schema. If two schemas share the same top-level type definition, you might encounter an error like this:

Found conflicting definitions for GraphQL type 'collections_order_by'. The definition at query_root.near.collections.order_by differs from the definitions at [query_root.aptos.nftz.order_by.collection, query_root.aptos.collections_search_aggregate.order_by, query_root.aptos.collections_search.order_by, query_root.aptos.collections_aggregate.order_by, query_root.aptos.collections.order_by, query_root.aptos.actions.collection.edition_launches.order_by.collection, query_root.aptos.actions.collection.attributes.nft.listings.order_by.collection, query_root.aptos.actions.collection.attributes.nft.bids.order_by.collection, query_root.aptos.actions.collection.attributes.order_by.collection, query_root.aptos.actions.order_by.nft.collection, query_root.aptos.actions.order_by.collection]

With the most important part being the first statement:

Found conflicting definitions for GraphQL type ‘collections_order_by’

This error means that the same type is defined in multiple places, creating a conflict that Hasura cannot resolve automatically. In such cases, Hasura offers a mechanism to rename conflicting types using namespaces or prefixes.

From the Remote Schemas tab, after filling in your schema's details, click GraphQL Customizations and add your customization values here.

Customize namespacing and prefixing from the Console