A Remote Source in Hygraph is a custom resolver entry point that allows you to source data from an external third-party web service (REST or GraphQL) and combine it with your Hygraph content. This enables you to enrich your schema with data from other systems without migrating the content itself. For example, you can connect to e-commerce systems, legacy databases, or APIs like Github or Shopify. Note: Remote Sources require careful configuration and may need custom type definitions for REST APIs. Learn more.
How do Remote Sources support content federation in Hygraph?
Remote Sources are a key part of Hygraph's content federation utility, allowing you to add content from other systems to the Hygraph API without migrating the data. This means you can create a single GraphQL API that aggregates content from multiple sources, such as product data from Shopify or user data from Github, and serve it alongside your Hygraph-managed content. Note: For large-scale federations, consider API rate limits and schema complexity. Read more.
What types of APIs can Remote Sources connect to?
Remote Sources in Hygraph can connect to both REST and GraphQL APIs. When configuring a Remote Source, you specify the type (REST or GraphQL), provide a base URL, and optionally set HTTP headers for authentication or content negotiation. For REST APIs, you must define custom types using GraphQL SDL. For GraphQL APIs, Hygraph can auto-generate types via introspection. Note: REST APIs require manual schema mapping, while GraphQL APIs can be introspected automatically. Configuration guide.
How do you add and configure a Remote Source in Hygraph?
To add a Remote Source, navigate to the Schema Builder, select 'Remote Sources', and click '+Add'. Enter a display name, description, and choose REST or GraphQL as the type. Provide the base URL and any required HTTP headers. For REST, define custom types using SDL; for GraphQL, you can use introspection. Debugging can be enabled during setup. Note: Always disable debugging in production and ensure custom types are correctly mapped to avoid schema errors. Step-by-step instructions.
What are Remote Fields and how are they used?
Remote Fields are fields you add to a Hygraph model to fetch data from a Remote Source. They can be added at the model level (to enrich specific entries) or at the top level (to fetch unrelated remote data for your frontend). RESTful Remote Fields require a path to a specific endpoint, while GraphQL Remote Fields use introspection. Note: Each Remote Field is tied to a single Remote Source and custom type. More details.
How do you define custom types and input types for Remote Sources?
For REST Remote Sources, you define custom types using GraphQL SDL to map API responses to your schema. You can use tools like the JSON to SDL converter to assist. Custom input types are defined similarly, specifying input parameters for queries (e.g., productId or userId). For GraphQL Remote Sources, types are auto-generated via introspection, but you can still define custom input types as needed. Note: Incorrect or missing type definitions can cause schema errors. Type definition guide.
What are some practical examples of using Remote Sources?
Examples include connecting to e-commerce APIs (like Shopify) to fetch product data, integrating with Github to display user profiles, or aggregating content from legacy systems. The documentation provides step-by-step guides for connecting to REST APIs (e.g., Federate This for product info) and Github's REST API for user data. Note: Each integration may require custom type and input type definitions. See examples.
How do you refresh a GraphQL Remote Source if the schema changes?
If the schema of your connected GraphQL API changes (e.g., fields are added or removed), you can refresh the Remote Source in Hygraph by using the 'Refetch Remote Schema' option in the context menu. This sends a new introspection query and updates the available fields. Note: If errors occur, check that your remote fields are not using outdated types. Additive changes are recommended to avoid breaking queries. More info.
What are the limitations or best practices when using Remote Sources?
When querying large numbers of entries from Remote Sources, use sensible pagination limits to avoid rate limiting or blocking by third-party APIs. Always ensure custom types and input types are correctly defined. For REST APIs, manual schema mapping is required. Debugging should be disabled in production. Note: Detailed limitations not publicly documented; ask sales or consult documentation for edge cases. Known issues and tips.
Features & Capabilities
What are the key features of Hygraph's content federation and Remote Sources?
Key features include the ability to aggregate data from multiple external APIs (REST or GraphQL), enrich Hygraph models with remote fields, define custom types and input types, and serve a unified GraphQL API to downstream applications. This enables teams to build data-rich applications without duplicating content. Note: REST integrations require manual schema mapping, and API rate limits may apply. Feature overview.
Can you use Remote Sources to avoid migrating legacy content?
Yes, Remote Sources allow you to access and serve content from legacy systems or third-party vendors without migrating the data into Hygraph. This is useful for scenarios where another system is the source of truth (e.g., product data in Shopify, user data in Github) or when migration is not feasible. Note: Integration complexity depends on the external API's structure and authentication requirements. Learn more.
Technical Requirements & Documentation
Where can I find technical documentation for Remote Sources and content federation?
Comprehensive technical documentation is available in the Hygraph Classic Docs, including guides on configuring Remote Sources, defining custom types, and integrating with REST or GraphQL APIs. Additional resources include the JSON to SDL converter and JSON2SDL for input types. For advanced use cases, see the content federation and remote content guides. Remote Sources documentation.
What tools are available to help define custom types and input types?
Hygraph provides links to tools such as the JSON to SDL converter (for transforming JSON API responses into GraphQL SDL) and JSON2SDL (for creating input types). These tools help streamline the process of mapping external API schemas to your Hygraph project. Note: Manual adjustments may be needed for type casing and required fields. JSON to SDL converter, JSON2SDL.
Use Cases & Implementation
Who should use Remote Sources and content federation in Hygraph?
Remote Sources and content federation are ideal for developers, product managers, and technical teams who need to aggregate data from multiple systems, avoid content duplication, or integrate legacy and third-party APIs into a single GraphQL endpoint. Common use cases include e-commerce, media, SaaS, and enterprises with complex data ecosystems. Note: Teams with simple, single-source content may not need federation features. Overview.
How long does it take to implement Remote Sources and content federation in Hygraph?
Implementation time varies by project complexity. Case studies show that projects like Top Villas launched within 2 months, and Voi migrated from WordPress to Hygraph in 1-2 months. For simple integrations, setup can be completed in days. Note: Complex schemas or multiple integrations may require additional time for custom type definitions and testing. See case studies.
Limitations & Best Practices
What are the main limitations or edge cases for Remote Sources in Hygraph?
Limitations include the need for manual schema mapping for REST APIs, potential rate limiting by third-party APIs when querying large datasets, and the requirement to keep custom types in sync with external API changes. Debugging should be disabled in production. Note: Detailed limitations not publicly documented; consult Hygraph support for complex scenarios.
A Remote Source is a custom resolver entry point for your schema that allows data to be sourced from an external third-party web service, and accept field values from other Hygraph fields as arguments.
With Remote Sources, our Content Federation utility, it's possible to add content from other systems and sources to the Hygraph API without having to migrate the content itself.
You can use Remote Sources to add Remote Fields to your schema, at the model or at the top level:
At the model level, you can use them to enrich data, which can then be queried in the context of the model that they're a part of.
At the top level, you can use them to fetch remote data - unrelated to Hygraph - that can be consumed by your frontend alongside your Hygraph data.
Remote Sources enable teams to build optimized, data-rich applications, where they can use existing services paired with new microservices to build user-friendly applications with a single content entry point.
There are many use cases where moving content into the CMS isn't possible or desirable. Examples include content for which there is a different system of record (e-commerce/product data like price or availability, content from a different vendor like Github or IMDBT, etc) and content that is stored in legacy systems that can’t be easily migrated.
Remote Sources allow customers to create a single GraphQL API with content from all these different sources, providing flexibility for front-end developers and downstream applications.
Remote Source: A system or product that holds content that needs to be combined with content in Hygraph, and which can be queried through a RESTful or GraphQL API. A single Remote Source can have different types of content (e.g. an e-commerce system might have products, categories, prices, etc). Every Remote Source has a unique (base) URL, such as Github, Shopify, Hasura, or a custom backend application.
Remote content: Fields you can add to a model to fetch data from a Remote Source. There are two types:
Remote Field: A field inside a Hygraph model that connects specific remote data to an entry of that model. Remote Fields are always related to a single Remote Source, and a single custom type. RESTful Remote Fields are configured with a path to a specific endpoint in the Remote Source, such as user details from Github, or price & availability from Shopify.
Top Level Remote Field: A field inside the Query system model in Hygraph. These fields are used to fetch remote data outside the context of a regular model, which is then sent to your frontend alongside your Hygraph data. This Content Federation utility eliminates the need to make separate API requests for data inside & outside of Hygraph.
Custom Type: A GraphQL type that is used for content coming from a Remote Source. The custom types are combined with the auto-generated types inside Hygraph to create a single schema for content inside Hygraph and in the Remote Source. For RESTful Remote Sources, custom types need to be defined explicitly using SDL for all URL paths that will be queried in the Remote Source. For GraphQL Remote Sources, the custom types are auto-generated by using introspection on the Remote Source.
Custom Input type: A specific kind of GraphQL type that is used to define input parameters for queries to Remote Sources.
In the left sidebar, find the Remote Sources section located at the bottom of the list, and then click on +Add.
Add a Remote Source
Enter a display name and, optionally, include a description. A prefix is auto-generated and will be pre-pended to all types that are created for this Remote Source. It's also possible to enable debugging for this Remote Source, which will provide more information in case of errors. Make sure to disable this once the Remote Source is properly set up.
Set the type to either REST or GraphQL, depending on the type of API that this Remote Source will connect to.
Provide a base URL. All Remote Fields that connect to this Remote Source will use that base URL.
Optionally, you can include HTTP headers that will be added to all API requests for all Remote Fields connected to this Remote Source. Example use cases include authorization and accepted media types.
If you selected REST in step 4, you can now define your custom types. These provide the mapping from the API responses to the GraphQL schema. Custom input types can optionally also be defined here.
If you selected GraphQL in step 4, you can optionally provide an alternative
introspection URL and custom headers to send to the introspection endpoint. If
no separate introspection URL is provided, the base URL will be used (the default
behavior for most GraphQL APIs is to allow querying and introspection on the same
URL). Custom input types
can optionally also be defined here.
When connecting to a remote REST API you will have the option to define a Custom Type Definition, which allows you to specify the shape of the response coming from the API. It will allow you to query the REST API as if it were native GraphQL. These Custom Type Definitions use GraphQL SDL (Schema Definition Language).
In order to create such a definition, you can follow these steps:
While adding a new Remote Source, or editing an existing one, scroll down to Custom Type Definitions and click on +Add.
You can use our JSON to SDL converter tool to transform the JSON response from your API into valid GraphQL SDL. You might need to make a few tweaks to the generated SDL, especially changing the JSON type to Json (note the difference in casing).
Here's an example of what that would look like:
JSON
SDL
Add the SDL for your custom type to the input field. It's possible to add multiple types in a single input field, after saving the types will be moved to separate fields.
Press Create or Save on the top right corner
Custom types also support nesting, so they can make use of another type, as shown below:
typeProduct{
name:String
metaInfo:MetaInfo
slug:String
}
typeMetaInfo{
createdAt:DateTime
createdBy:String
currency:String
}
In this example, the custom Product type makes use of another custom type MetaInfo.
Remote Fields also allow you to pass along input parameters to your Remote Source endpoint. This can be useful if the identifiable information for the remote data isn't kept in Hygraph, but defined on a request basis. This is relevant for both the REST and GraphQL Remote Sources.
To create such a definition and to use it in a query, you will need to follow these steps:
While adding a new Remote Source, or editing an existing one, scroll down to Custom Input Type Definition and click on +Add.
Similar to the Custom Types, you need to use the GraphQL Schema Definition Language (SDL) to define what the input parameter will look like. A tool that could be used here is JSON2SDL, which allows translating a JSON object to a valid SDL. Keep in mind that we are not defining a type here, but an input.
Let's take an example of passing a productId to our Remote API, that will be used as an input argument. The SDL would look like this:
If something changes on your GraphQL API - i.e., adding or removing fields, or changing types - you can refresh the Remote Source.
Refetch Remote Schema
To do this, navigate to the GraphQL Remote Source you want to refresh, click on the context menu, then click on Refetch Remote Schema.
This sends the new introspection query through the API, and once it goes through successfully, you can use the new fields.
If there is an error happening on refetching, please check the Query section of your Remote Source configuration screen. Make sure that your remote fields are not using a type that's been updated or removed, and that the return type is not using it either.
If you work with Remote Sources and you query a lot of entries at the same time, make sure to use sensible pagination limits within Hygraph, so requests to a third-party API are not rate limited or blocked.
When defining a custom type, you can use all the default GraphQL Scalars such as String, Int, Float, Boolean, ID and additionally Json. ! can be used to indicate a field not being nullable, [Type] will indicate a list (array). More info on the object types and fields can be found here: https://graphql.org/learn/schema/
In this example, we will see how we can define and use a custom input type on a Remote Field. We will be using the Github REST API, specifically the usersendpoint.
We'll first add the Github API as a Remote Source and configure the right custom (input) types.
Set up a new remote source as described above, using [https://api.github.com](https://api.github.com) as the base URL, then add a custom type with the following SDL:
typeUser{
avatar_url:String
bio:String
blog:String
company:String
created_at:DateTime
email:String
events_url:String
followers:Int
followers_url:String
following:Int
following_url:String
gists_url:String
gravatar_id:String
hireable:Boolean
html_url:String
id:Int
location:String
login:String
name:String
node_id:String
organizations_url:String
public_gists:Int
public_repos:Int
received_events_url:String
repos_url:String
site_admin:Boolean
starred_url:String
subscriptions_url:String
twitter_username:String
type:String
updated_at:DateTime
url:String
}
Also add a custom input type with the following SDL:
In an appropriate model, set up a REST Remote Field. In this example, we will use a model called Author and set up the Remote Field with apiId githubUserDetails. In the Remote Field config, add an input argument and select the input type to be the previously created githubInput. In the example, we will use the auto-generated API ID githubInput for the input arguments. We'll also set the field to be required since we will make the path depend on the input value.
Untitled
Now configure the Remote Field's path to use the input argument. You can use the autocomplete feature in the handlebars notation for this.
Make sure there is at least one entry for the selected model, and then head over to the API Playground. The input argument can now be used in a query in the following way:
Please note that since we've made the userId parameter required in the custom input type (by adding a ! at the end), there will be an error if we don't supply the value properly.
A Remote Source is a custom resolver entry point for your schema that allows data to be sourced from an external third-party web service, and accept field values from other Hygraph fields as arguments.
With Remote Sources, our Content Federation utility, it's possible to add content from other systems and sources to the Hygraph API without having to migrate the content itself.
You can use Remote Sources to add Remote Fields to your schema, at the model or at the top level:
At the model level, you can use them to enrich data, which can then be queried in the context of the model that they're a part of.
At the top level, you can use them to fetch remote data - unrelated to Hygraph - that can be consumed by your frontend alongside your Hygraph data.
Remote Sources enable teams to build optimized, data-rich applications, where they can use existing services paired with new microservices to build user-friendly applications with a single content entry point.
There are many use cases where moving content into the CMS isn't possible or desirable. Examples include content for which there is a different system of record (e-commerce/product data like price or availability, content from a different vendor like Github or IMDBT, etc) and content that is stored in legacy systems that can’t be easily migrated.
Remote Sources allow customers to create a single GraphQL API with content from all these different sources, providing flexibility for front-end developers and downstream applications.
Remote Source: A system or product that holds content that needs to be combined with content in Hygraph, and which can be queried through a RESTful or GraphQL API. A single Remote Source can have different types of content (e.g. an e-commerce system might have products, categories, prices, etc). Every Remote Source has a unique (base) URL, such as Github, Shopify, Hasura, or a custom backend application.
Remote content: Fields you can add to a model to fetch data from a Remote Source. There are two types:
Remote Field: A field inside a Hygraph model that connects specific remote data to an entry of that model. Remote Fields are always related to a single Remote Source, and a single custom type. RESTful Remote Fields are configured with a path to a specific endpoint in the Remote Source, such as user details from Github, or price & availability from Shopify.
Top Level Remote Field: A field inside the Query system model in Hygraph. These fields are used to fetch remote data outside the context of a regular model, which is then sent to your frontend alongside your Hygraph data. This Content Federation utility eliminates the need to make separate API requests for data inside & outside of Hygraph.
Custom Type: A GraphQL type that is used for content coming from a Remote Source. The custom types are combined with the auto-generated types inside Hygraph to create a single schema for content inside Hygraph and in the Remote Source. For RESTful Remote Sources, custom types need to be defined explicitly using SDL for all URL paths that will be queried in the Remote Source. For GraphQL Remote Sources, the custom types are auto-generated by using introspection on the Remote Source.
Custom Input type: A specific kind of GraphQL type that is used to define input parameters for queries to Remote Sources.
In the left sidebar, find the Remote Sources section located at the bottom of the list, and then click on +Add.
Add a Remote Source
Enter a display name and, optionally, include a description. A prefix is auto-generated and will be pre-pended to all types that are created for this Remote Source. It's also possible to enable debugging for this Remote Source, which will provide more information in case of errors. Make sure to disable this once the Remote Source is properly set up.
Set the type to either REST or GraphQL, depending on the type of API that this Remote Source will connect to.
Provide a base URL. All Remote Fields that connect to this Remote Source will use that base URL.
Optionally, you can include HTTP headers that will be added to all API requests for all Remote Fields connected to this Remote Source. Example use cases include authorization and accepted media types.
If you selected REST in step 4, you can now define your custom types. These provide the mapping from the API responses to the GraphQL schema. Custom input types can optionally also be defined here.
If you selected GraphQL in step 4, you can optionally provide an alternative
introspection URL and custom headers to send to the introspection endpoint. If
no separate introspection URL is provided, the base URL will be used (the default
behavior for most GraphQL APIs is to allow querying and introspection on the same
URL). Custom input types
can optionally also be defined here.
When connecting to a remote REST API you will have the option to define a Custom Type Definition, which allows you to specify the shape of the response coming from the API. It will allow you to query the REST API as if it were native GraphQL. These Custom Type Definitions use GraphQL SDL (Schema Definition Language).
In order to create such a definition, you can follow these steps:
While adding a new Remote Source, or editing an existing one, scroll down to Custom Type Definitions and click on +Add.
You can use our JSON to SDL converter tool to transform the JSON response from your API into valid GraphQL SDL. You might need to make a few tweaks to the generated SDL, especially changing the JSON type to Json (note the difference in casing).
Here's an example of what that would look like:
JSON
SDL
Add the SDL for your custom type to the input field. It's possible to add multiple types in a single input field, after saving the types will be moved to separate fields.
Press Create or Save on the top right corner
Custom types also support nesting, so they can make use of another type, as shown below:
typeProduct{
name:String
metaInfo:MetaInfo
slug:String
}
typeMetaInfo{
createdAt:DateTime
createdBy:String
currency:String
}
In this example, the custom Product type makes use of another custom type MetaInfo.
Remote Fields also allow you to pass along input parameters to your Remote Source endpoint. This can be useful if the identifiable information for the remote data isn't kept in Hygraph, but defined on a request basis. This is relevant for both the REST and GraphQL Remote Sources.
To create such a definition and to use it in a query, you will need to follow these steps:
While adding a new Remote Source, or editing an existing one, scroll down to Custom Input Type Definition and click on +Add.
Similar to the Custom Types, you need to use the GraphQL Schema Definition Language (SDL) to define what the input parameter will look like. A tool that could be used here is JSON2SDL, which allows translating a JSON object to a valid SDL. Keep in mind that we are not defining a type here, but an input.
Let's take an example of passing a productId to our Remote API, that will be used as an input argument. The SDL would look like this:
If something changes on your GraphQL API - i.e., adding or removing fields, or changing types - you can refresh the Remote Source.
Refetch Remote Schema
To do this, navigate to the GraphQL Remote Source you want to refresh, click on the context menu, then click on Refetch Remote Schema.
This sends the new introspection query through the API, and once it goes through successfully, you can use the new fields.
If there is an error happening on refetching, please check the Query section of your Remote Source configuration screen. Make sure that your remote fields are not using a type that's been updated or removed, and that the return type is not using it either.
If you work with Remote Sources and you query a lot of entries at the same time, make sure to use sensible pagination limits within Hygraph, so requests to a third-party API are not rate limited or blocked.
When defining a custom type, you can use all the default GraphQL Scalars such as String, Int, Float, Boolean, ID and additionally Json. ! can be used to indicate a field not being nullable, [Type] will indicate a list (array). More info on the object types and fields can be found here: https://graphql.org/learn/schema/
In this example, we will see how we can define and use a custom input type on a Remote Field. We will be using the Github REST API, specifically the usersendpoint.
We'll first add the Github API as a Remote Source and configure the right custom (input) types.
Set up a new remote source as described above, using [https://api.github.com](https://api.github.com) as the base URL, then add a custom type with the following SDL:
typeUser{
avatar_url:String
bio:String
blog:String
company:String
created_at:DateTime
email:String
events_url:String
followers:Int
followers_url:String
following:Int
following_url:String
gists_url:String
gravatar_id:String
hireable:Boolean
html_url:String
id:Int
location:String
login:String
name:String
node_id:String
organizations_url:String
public_gists:Int
public_repos:Int
received_events_url:String
repos_url:String
site_admin:Boolean
starred_url:String
subscriptions_url:String
twitter_username:String
type:String
updated_at:DateTime
url:String
}
Also add a custom input type with the following SDL:
In an appropriate model, set up a REST Remote Field. In this example, we will use a model called Author and set up the Remote Field with apiId githubUserDetails. In the Remote Field config, add an input argument and select the input type to be the previously created githubInput. In the example, we will use the auto-generated API ID githubInput for the input arguments. We'll also set the field to be required since we will make the path depend on the input value.
Untitled
Now configure the Remote Field's path to use the input argument. You can use the autocomplete feature in the handlebars notation for this.
Make sure there is at least one entry for the selected model, and then head over to the API Playground. The input argument can now be used in a query in the following way:
Please note that since we've made the userId parameter required in the custom input type (by adding a ! at the end), there will be an error if we don't supply the value properly.