Edit and preview content side-by-side with our new Live Preview
Hygraph
Docs

Remote Fields vs Top-level Remote Fields

#Overview

Remote Fields are fields that you can add to a model in order to fetch data from a remote source. There are two types:

  • Remote Field: A field inside a regular 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.

#Remote field types

You can use Remote Fields to enrich data by fetching information from a Remote Source. This data can be queried in the context of the model it's a part of.

Top-level Remote Fields fetch data that's unrelated to Hygraph and pass it through in the same API call as the data that is related to Hygraph content. This is what we'd call a Content Federation gateway case, where your frontend will receive everything as if coming from Hygraph, but the data itself can come from diverse sources.

#Remote Fields

Remote Fields - Model viewRemote Fields - Model view

Remote Fields are fields inside a Hygraph model that connect specific remote data to an entry of that model.

These 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.

#What you can do with Remote Fields

You can add Remote Fields to regular models in your schema to enrich data.

#Possible use cases for Remote Fields

  • They can facilitate e-commerce by consolidating product listings from multiple suppliers onto one platform.
  • In travel, they can integrate flight, hotel, and rental car information from numerous providers.
  • In stock management, they can provide real-time inventory data from various warehouses, enabling efficient tracking and management.

#Top-level Remote Fields

Top-level Remote Fields - Query modelTop-level Remote Fields - Query model

Top-level Remote Fields use the Query model, which is a custom resolver entry point for your schema that allows you to fetch remote data alongside the regular models in Hygraph.

You can find the Query model by navigating to the schema builder of your project.

These Top-level Remote Fields exist in their own model in the schema - the Query model - and you can use them to go beyond the content enrichment case by passing data that is unrelated to the content you have in your Hygraph project.

#What you can do with Top-level Remote Fields

  • You can use this model to pass data through our Content API without the need for it to be associated to a Hygraph content entry. In other words, you can use this model as a top-level entry point to fetch external data.
  • Take advantage of our Content Federation capabilities by integrating more systems and using them independently from their Hygraph content.

#Possible use cases for Top-level Remote Fields

  • Data ownership needs to stay within the external system rather than being mirrored into another system.
  • You are working with a multi-layered infrastructure where data enrichment happens before the data reaches Hygraph.
  • Your website makes calls to APIs that are not related to Hygraph.
  • You are working on a project where not all content entries need enrichment.