Odyssey

GraphOS: From Development to Launch

Workshop introFollow-along: GraphOS ExplorerExercise: Explore ExplorerGraphOSExercise: Creating a supergraphFollow-along: Metrics and observabilityFollow-along: Using `@defer`Making changes to the supergraphFollow-along: Schema checks & deployFollow-along: Schema publishExercise: Schema checksWhat's in a supergraph?Exercise: Add a subgraphExercise: Exploring entities & rover devFollow-along: Connecting data with entitiesWhat's next?
5. Exercise: Creating a supergraph
2m

Exercise: Creating a supergraph

🎯 Goal: Create a supergraph on GraphOS using your API endpoint (where it's running on Railway!). This will be the start of your Poetic Plates GraphQL API.

You'll need a Studio account with the Serverless plan.

Cloud-hosted supergraphs are currently only available on the Serverless (Free) or Serverless plan. If you created your Studio account or a new organization today, you will automatically have access to this plan.

You can check your organization's current plan in Apollo Studio. From your organization's page, go to the Settings tab and scroll down to the Plan and Billing section.

https://studio.apollographql.com

Check your plan

If you are on the legacy Free plan, you will need to convert to the Serverless (Free) plan. Click the Convert to Serverless (Free) button in the top-right corner of your organization's page in Studio.

If you are on the legacy Teams plan, or an Enterprise plan, you won't have access to cloud routing at this time. Create a new organization to continue with the hands-on portions of the course.

If you already have a GraphOS account with existing graphs, click the Create New Graph button. Then, walk through the steps to create a supergraph.

If you see the flow below, you're in the right place! Go ahead and walk through the steps to create your supergraph.

https://studio.apollographql.com

Create a new graph

If you don't see that screen, then follow the "Before you start: Check your plan" section above.

Questions to think about

  1. What's a good name for this first subgraph? Think: what business domain is it focused on? Here's the subgraph name we used:

    Subgraph name
    recipes
  2. What's the difference between the supergraph ID and the supergraph name? When/where would the ID or the name be used in: the developer workflow? GraphOS?

    Answer
    The supergraph ID will be used to reference your supergraph from various tools later on.
    It CANNOT be changed.
    The supergraph name can be changed at any time.
    It's displayed throughout Studio.
    It's usually how you refer to your supergraph with your teammates.

Configuring CORS

Currently, our supergraph is ready to be queried—but only through Studio. This is because the cloud router we've set up for our supergraph needs to be specifically configured to allow other origins to access it.

We can update these settings right in Studio.

  1. Navigate to our newly-created supergraph's Settings page, under the This variant tab.

  2. Click into the Cloud Router option, and scroll down to the section titled Router configuration YAML.

    https://studio.apollographql.com

    The Router Configuration page in Apollo Studio

    Router Configuration YAML
    cors:
    origins:
    - https://studio.apollographql.com
    headers:
    subgraphs:
    recipes:
    request:
    - propagate:
    matching: ".*"
  3. Remove the origins list. Below (still nested within the cors property), we're going to add a new property called allow_any_origin and set it to true.

    Router Configuration YAML
    cors:
    allow_any_origin: true

    Then, hit Save.

    https://studio.apollographql.com

    The Router Configuration page in Apollo Studio, with localhost added and the Save icon emphasized

If we didn't set this option, client app developers would see an error in their browser, noting that their localhost or production URL has been blocked by CORS policy.

In this workshop, we're building Poetic Plates as an API that lets any web client or API consumer to send requests to it. If you're building an API that needs stricter rules, the cloud router does provide additional CORS options, such as:

  • setting a list of allowed origins
  • allowing credentials (for example, using cookies or authorization headers) from clients
  • setting allowed request methods

You can find a full list of CORS options in the Apollo documentation.

In future courses on Odyssey, you can discover more techniques to secure your supergraph. In the meantime, you can check out the Apollo technote about the topic.

Task!
Previous
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.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              GraphQL

              An open-source query language and specification for APIs that enables clients to request specific data, promoting efficiency and flexibility in data retrieval.

              supergraphs

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              Serverless

              A legacy Apollo plan with both free and paid versions that lets you run a cloud router on shared infrastructure. Intended for developers and teams evaluating GraphOS.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              graphs

              A schema-based data model representing how different data elements interconnect and can be accessed.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              subgraph

              A service in a federated GraphQL architecture. Acts as a module for a supergraph. Includes both GraphQL services and REST services integrated via Apollo Connectors.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              cloud router

              A cloud-hosted, automatically provisioned supergraph routing runtime. Implemented with a fleet of GraphOS Routers and available on Dedicated and Serverless plans.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              cloud router

              A cloud-hosted, automatically provisioned supergraph routing runtime. Implemented with a fleet of GraphOS Routers and available on Dedicated and Serverless plans.

              Odyssey

              Apollo's official learning platform, featuring interactive tutorials, videos, code challenges, and certifications.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              NEW COURSE ALERT

              Introducing Apollo Connectors

              Connectors are the new and easy way to get started with GraphQL, using existing REST APIs.

              Say goodbye to GraphQL servers and resolvers—now, everything happens in the schema!

              Take the course