Hygraph
Docs

#Lesson 5.3 - Add top-level remote fields

In this lesson, you will add a top-level remote field to the Query system model and run a test query to confirm the remote source is working correctly.

A top-level remote field fetches remote data outside the context of any model entry. Where the remote field added in lesson 5.2 only returns reviews for a specific product, a top-level remote field can return review data independently. This is useful for fetching all reviews, or for passing in an argument from the frontend rather than from a content entry.

#Add a top-level remote field

You will add the field to the Query system model using the same HyDemoAPI remote source.

Complete top-level remote field configurationComplete top-level remote field configuration

  1. Open the Query model in the Schema editor and from the right sidebar, add a REST remote field.

  2. Fill in the following information:

    FieldInput
    Display nameReviews
    API IDAuto-completed. Leave as is.
    Remote sourceHyDemoAPI is selected by default. Leave as is.
    MethodGET is selected by default. Leave as is.
    Return typeSelect Reviews from the dropdown
    Input argumentsClick + Add input argument to reveal the argument fields
    Input typeString
    API IDproductSlug
    Make field requiredSelect checkbox
    Path/api/reviews/product/{{args.productSlug}}

    The Path appends to the remote source base URL. The {{args.productSlug}} path argument is supplied by whoever runs the query: a frontend component, a developer testing in the API Playground, or any API client. This means the top-level remote field has no dependency on Hygraph content. It can be queried even if the Product model contains no entries at all.

    The remote field in lesson 5.2 works differently. Its path uses {{doc.productSlug}}, which pulls the productSlug value from the specific Product entry being queried. The top-level remote field removes that dependency entirely.

  3. Click Add to save.

#Test the top-level remote field

Because the top-level remote field is not connected to a content entry, it can be tested immediately without creating any content first.

  1. Navigate to the API Playground.

  2. Run the following query:

The response confirms the remote source is correctly configured. The Hygraph API returns external review data without any data migration and without a separate API call from the frontend. This is Content Federation working as intended.

The schema is now complete. Content creation starts in the next lesson.

#What's next

Lesson 6 - Content

Or, go to the Tutorial overview for the full lesson list.