#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 configuration
-
Open the Query model in the Schema editor and from the right sidebar, add a REST remote field.
-
Fill in the following information:
Field Input Display name Reviews API ID Auto-completed. Leave as is. Remote source HyDemoAPI is selected by default. Leave as is. Method GET is selected by default. Leave as is. Return type Select Reviewsfrom the dropdownInput arguments Click + Add input argument to reveal the argument fields Input type String API ID productSlug Make field required Select checkbox Path /api/reviews/product/{{args.productSlug}}The
Pathappends 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 theProductmodel contains no entries at all.The remote field in lesson 5.2 works differently. Its path uses
{{doc.productSlug}}, which pulls theproductSlugvalue from the specificProductentry being queried. The top-level remote field removes that dependency entirely. -
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.
-
Navigate to the API Playground.
-
Run the following query:
QueryResponse
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 - ContentOr, go to the Tutorial overview for the full lesson list.