4. Defining a @source
2m

(Text covers the exact same content as the video)

Practice

The @source directive
The @source directive takes in a few parameters to help us define a shared data source for multiple Connectors. The name parameter is a 
 
 for the data source. The 
 
 parameter defines the REST API endpoint we want to connect to. We can also set headers that we want to pass to the REST API using the 
 
 parameter.

Drag items from this box to the blanks above

  • Connector

  • http.baseURL

  • http.restAPI

  • http.headers

  • http.restHeaders

  • unique identifier

  • headers

Code Challenge!

Define a @source named outerspace that points to the URL http://outerspace-api.example/. Include a header named x-caller with a hard-coded value of space-schema. Review the previous lesson for a refresher on the @source parameters and how to include headers.

Key takeaways

  • The @source defines a shared data source for multiple Connectors.
  • The @source takes in two parameters: name and http.

Up next

There's one thing we're missing from our schema: the endpoint we should connect to. Let's fix this build error in the next lesson!

Next

Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.