Skip to content

Commit 694b596

Browse files
authored
Merge branch 'main' into adding-additional-checks
2 parents 439ba29 + f8779c9 commit 694b596

File tree

6 files changed

+108
-209
lines changed

6 files changed

+108
-209
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Validation Tests
22

33
on:
44
pull_request:
5-
branches: [ main, 'releases/**' ]
5+
branches: [ main, 'releases/**', 'release/**' ]
66
push:
7-
branches: [ main, 'releases/**' ]
7+
branches: [ main, 'releases/**', 'release/**' ]
88

99
jobs:
1010
test:

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"display_name": "Start with REST",
66
"path": "start-with-rest",
77
"language": "GraphQL",
8-
"federation_version": "=2.10.0",
8+
"federation_version": "=2.11.0",
99
"max_schema_depth": 5,
1010
"routing_url": "http://ignore",
1111
"test_commands": ["echo \"REST template test coming soon\""],

start-with-rest/getting-started.md

Lines changed: 50 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,76 @@
1-
👋 Hi there! This guide walks you through integrating REST APIs into your graph using [Apollo Connectors](https://www.apollographql.com/docs/graphos/schema-design/connectors).
2-
3-
- [Setup](#setup)
4-
- [Part two: Check out how Connectors work](#part-two-check-out-how-connectors-work)
5-
- [Time to build your API](#time-to-build-your-api)
6-
- [Debugging your schema](#debugging-your-schema)
7-
- [Design your schema with Apollo’s IDE extensions](#design-your-schema-with-apollos-ide-extensions)
8-
- [Check for errors each time you save](#check-for-errors-each-time-you-save)
9-
- [Debug Connectors in Sandbox](#debug-connectors-in-sandbox)
1+
2+
- [Overview](#overview)
3+
- [Designing your graph](#designing-your-graph)
4+
- [IDE extensions for graph development](#ide-extensions-for-graph-development)
5+
- [Working on your graph locally](#working-on-your-graph-locally)
6+
- [The design process](#the-design-process)
7+
- [Debugging Apollo Connectors](#debugging-apollo-connectors)
108
- [Publishing changes to GraphOS Studio](#publishing-changes-to-graphos-studio)
9+
- [Deploying Apollo Router](#deploying-apollo-router)
1110
- [Security](#security)
1211
- [Additional resources](#additional-resources)
13-
- [Deploying your graph](#deploying-your-graph)
14-
- [More on graph development](#more-on-graph-development)
15-
- [More about Connectors](#more-about-connectors)
16-
17-
# Setup
18-
19-
1. Open `products.graphql` to take a look at your graph's starter schema. Ignore the comments labeled with a ✏️ for now, we’ll get to them later.
20-
2. In the terminal, run the `rover dev` command provided in the output of `rover init` under **Next steps**. The `dev` command starts a local development session and gives you access to Apollo Sandbox—a local, in-browser GraphQL playground, where you can run GraphQL operations and test your API as you design it.
21-
3. In Sandbox, paste the following GraphQL query in the **Operation** section:
22-
23-
```
24-
query GetProducts {
25-
products {
26-
id
27-
name
28-
description
29-
}
30-
}
31-
```
32-
33-
4. Click `► GetProducts` to run the request. You'll get a response back with data for the product's id, name, and description; exactly the properties you asked for in the query! 🎉
34-
35-
## Part two: Check out how Connectors work
36-
37-
1. Let's find out where this data is coming from. Click the arrow next to **Response** and select the **Connectors Debugger** option.
38-
2. Now, click the most recent request to review its details. In the **Request overview** tab, press the **cURL** button to copy the underlying HTTP request made to the REST API.
39-
3. Run this request in your terminal and compare it with what’s been configured using the `@connect` directive in `products.graphql`. You'll notice that some properties in the terminal response match to the `selection` mapping in the schema. This is the key to how Connectors work!
40-
41-
Hooray! You ran a query, got some data back, and reviewed what Connectors are like under the hood! Feel free to experiment some more–try tweaking the query to see what data you can retrieve. 🚀
12+
- [Graph development](#graph-development)
13+
- [Connectors](#connectors)
14+
- [Apollo Router](#apollo-router)
4215

43-
# Time to build your API
4416

45-
You’re all set to start building. You'll be working primarily with the `products.graphql` file.
17+
# Overview
4618

47-
First, make sure you’ve installed and configured [your IDE extension of choice](https://www.apollographql.com/docs/graphos/schema-design/ide-support) so you can rely on its autocompletion, schema information, and syntax highlighting features.
19+
👋 Hi there!
4820

49-
Then, follow the development cycle below:
21+
Your new graph is set up with [Apollo Federation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/federation). This means it’s built to grow, even if you’re starting with just one service. Right now, that service is defined in `products.graphql`, and you can treat it like a regular GraphQL API as you build it out.
5022

51-
1. [Add your REST API details using @source](https://www.apollographql.com/docs/graphos/schema-design/connectors/directives#source).
52-
2. Define the types and fields you want your GraphQL API to expose. Use the inline comments labeled with a ✏️ to follow along.
53-
3. [Configure the Connector's request details](https://www.apollographql.com/docs/graphos/schema-design/connectors/requests).
54-
4. [Configure the Connector's response mapping](https://www.apollographql.com/docs/graphos/schema-design/connectors/responses). You can use the [Connectors Mapping Playground](https://www.apollographql.com/connectors-mapping-playground) to help convert JSON responses to and from GraphQL types.
55-
5. Run operations and debug your API following the instructions in the section below.
23+
This project is also set up to use [Apollo Router](https://www.apollographql.com/docs/graphos/routing) as the entry point for all requests to your graph. It’s a great way to get features like tracing, metrics, and caching out of the box. It gives you a single place to configure settings for your graph, like traffic shaping, authorization, and more. For now, the router simply forwards requests to your service, but as your graph grows, it can pull data from multiple places and return one clear, consistent result.
5624

57-
📓 **Note:** If you’re working with APIs that require headers, you’ll need to include them in `products.graphql` and add a router configuration file (`router.yaml`) to your project directory.
25+
Finally, this graph also uses [Apollo Connectors](https://www.apollographql.com/docs/graphos/connectors), which let you integrate REST APIs directly into your GraphQL schema without writing any resolver code or deploying a backend GraphQL server. Instead of building separate services to connect your APIs, you simply add declarative directives such as `@connect` and `@source` to your schema, and Apollo Router automatically handles the REST API calls and data transformation for you.
5826

59-
To learn more about headers and other advanced features like configuring environment variables, telemetry, and authentication, visit [Apollo’s docs on working with Router](https://community.apollographql.com/c/graph-os/getting-started/35).
27+
# Designing your graph
6028

61-
ℹ️ **Tip:** If you run into any issues or difficulties, please reach out via the [Apollo Community](https://community.apollographql.com/c/graph-os/getting-started/35). Click **New Topic** to start a discussion–the Apollo team is here to help!
29+
## IDE extensions for graph development
6230

63-
# Debugging your schema
31+
[Apollo’s IDE extensions](https://www.apollographql.com/docs/ide-support) are designed to help you catch and correct any issues related to schema design as early as possible. Lean on their instant feedback and autocomplete capabilities to help you create the types, fields, arguments, and connectors.
6432

65-
The Apollo dev toolkit includes a few debugging tools to help you design and develop your graph. The journey looks a little something like this:
33+
## Working on your graph locally
6634

67-
1. Design your schema with Apollo’s IDE extensions
68-
2. Check for errors each time you save
69-
3. Debug Connectors in Sandbox
70-
4. Rinse and repeat until you're happy with your API!
35+
After completing the `rover init` flow, run the command you see in your terminal under **Next steps** (it will start with your `APOLLO_KEY`). This allows you to work with Apollo Router locally, giving you a way to design and test your supergraph in a safe environment, without the need to deploy anything yet.
7136

72-
## Design your schema with Apollo’s IDE extensions
37+
You’ll get automatic [build checks](https://www.apollographql.com/docs/graphos/platform/schema-management/checks#build-checks-1), so you can identify issues early and make sure your services work together. It’s a fast way to iterate with confidence before going live.
7338

74-
Apollo’s IDE extensions are designed to help you catch and correct any issues related to schema design as early as possible. Lean on their instant feedback and autocomplete capabilities to help you create types, fields, arguments, and Connectors.
39+
Once you run the command, the CLI will start watching your files for updates. Every time you make a change, Rover checks to see if the schema is valid. You can think of it as “hot-reloading” for your GraphQL schema. [More details about the dev command](https://www.apollographql.com/docs/rover/commands/dev).
7540

76-
## Check for errors each time you save
41+
## The design process
7742

78-
When you run `rover dev`, Rover starts watching your files for updates. Every time you make a change, Rover checks to see if the schema is valid. You can think of it as “hot-reloading” for your GraphQL schema. [More details about the dev command](https://www.apollographql.com/docs/rover/commands/dev).
43+
The best way to get started with schema design is to check out the different [schema types](https://www.apollographql.com/docs/graphos/schema-design) that make up your graph. You can also go straight to Apollo’s schema design guides, starting with [Demand-Oriented Schema Design](https://www.apollographql.com/docs/graphos/schema-design/guides/demand-oriented-schema-design).
7944

80-
## Debug Connectors in Sandbox
45+
## Debugging Apollo Connectors
8146

8247
![A screenshot of the Connectors debugger in Apollo Sandbox](connectors_debugger.png)
8348

84-
In Apollo Sandbox, you can access the Connectors Debugger by selecting it from the **Response** drop-down on the right side of your screen. The debugger will provide detailed insights into network calls, including response bodies, errors, and connector-related syntax. You can also visit Apollo's docs to [learn more about troubleshooting Connectors](https://www.apollographql.com/docs/graphos/schema-design/connectors/troubleshooting#return-debug-info-in-graphql-responses).
49+
In Apollo Sandbox, you can access the Connectors Debugger by selecting it from the Response drop-down on the right side of your screen. The debugger will provide detailed insights into network calls, including response bodies, errors, and connector-related syntax. You can also visit Apollo's docs to [learn more about troubleshooting Connectors](https://www.apollographql.com/docs/graphos/schema-design/connectors/troubleshooting#return-debug-info-in-graphql-responses).
8550

8651
# Publishing changes to GraphOS Studio
8752

88-
When you publish a schema to GraphOS, it becomes part of your schema’s version history and is available for checks, composition, and collaboration. When you run `rover init`, GraphOS takes care of your first publish for you.
53+
Publishing your graph saves your schema to the GraphOS registry, allowing you to track its evolution and collaborate smoothly with your team when needed. GraphOS handles your first publish for you during `init` and creates an environment (or graph variant) called `current`, but any subsequent changes you make will require additional publishes.
8954

90-
Once you’ve made changes to your schema files and are happy with the state of your API, or if you’d like to test the experience of publishing schema changes to GraphOS Studio, paste and run the following command in your terminal:
55+
Once you're happy with the state of your graph, replace the placeholder items in this command with your own and run it:
9156

9257
```
93-
rover subgraph publish your-graph-id@main \ # Replace this with your `APOLLO_GRAPH_REF` value
58+
rover subgraph publish your-graph-id@current \ # Replace this with your APOLLO_GRAPH_REF value
9459
--schema "./products.graphql" \
95-
--name products-subgraph \
96-
--routing-url "https://my-running-subgraph.com/api" # If you don't have a running API yet, you can replace this with http://localhost:4000
60+
--name products \
9761
```
9862

99-
📓 **Note:** For production-ready APIs, [integrating Rover into your CI/CD](https://www.apollographql.com/docs/rover/ci-cd) ensures schema validation, reduces the risk of breaking changes, and improves collaboration.
63+
**📓 Note:** The `rover subgraph publish` command usually includes a `--routing-url` flag, which is only required during your first publish or any time you want to change your routing URL. Otherwise, this flag can be left out. [Review other command options](https://www.apollographql.com/docs/rover/commands/subgraphs#publishing-a-subgraph-schema-to-graphos).
64+
65+
# Deploying Apollo Router
66+
67+
For your supergraph to work, two things must be true:
68+
69+
**The Apollo Router must be deployed.** The Router is what makes your graph live. It connects to GraphOS to fetch your published schema and serves a single GraphQL endpoint for your clients. It handles the work of calling the right subgraphs and combining their results behind the scenes.
70+
71+
**Each service needs to be reachable by the router.** When working with Apollo Connectors, your services become reachable via the REST API(s) you bring into your schema(s).
72+
73+
If you already know how to deploy and host the router, excellent! If you’d like some guidance for this step, [head over to Studio](https://studio.apollographql.com/) to set your endpoint and review deployment options.
10074

10175
# Security
10276

@@ -105,23 +79,19 @@ For a more secure and reliable API, Apollo recommends updating your CORS policy
10579
- Specifying which origins, HTTP methods, and headers are allowed to interact with your API
10680
- Turning off GraphQL introspection to limit the exposure of your API schema
10781

108-
Making these updates helps safeguard your API against common vulnerabilities and unauthorized access. To learn more, [review Apollo’s documentation on Graph Security](https://www.apollographql.com/docs/graphos/platform/security/overview).
82+
Making these updates helps safeguard your API against common vulnerabilities and unauthorized access. To learn more, check out [Apollo’s documentation on Graph Security](https://www.apollographql.com/docs/graphos/platform/security/overview).
10983

11084
# Additional resources
11185

112-
## Deploying your graph
113-
114-
- [Supergraph routing with GraphOS Router](https://www.apollographql.com/docs/graphos/routing/about-router)
115-
- [Self-hosted Deployment](https://www.apollographql.com/docs/graphos/routing/self-hosted)
116-
- [Router configuration](https://www.apollographql.com/docs/graphos/routing/configuration)
117-
118-
## More on graph development
119-
86+
## Graph development
12087
- [Introduction to Apollo Federation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/federation)
12188
- [Schema Design with Apollo GraphOS](https://www.apollographql.com/docs/graphos/schema-design)
12289
- [IDE support for schema development](https://www.apollographql.com/docs/graphos/schema-design/ide-support)
12390

124-
## More about Connectors
91+
## Connectors
92+
- [Apollo Connectors Quickstart](https://www.apollographql.com/docs/graphos/connectors/getting-started)
93+
- [Connectors Community Repo](https://github.com/apollographql/connectors-community)
12594

126-
- [Tutorial: GraphQL meets REST with Apollo Connectors](https://www.apollographql.com/tutorials/connectors-intro-rest)
127-
- [Connectors Community Repo](https://github.com/apollographql/connectors-community)
95+
## Apollo Router
96+
- [Self-hosting the Apollo Router](https://www.apollographql.com/docs/graphos/routing/self-hosted)
97+
- [Router configuration](https://www.apollographql.com/docs/graphos/routing/configuration)

start-with-rest/products.graphql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ extend schema
99
url: "https://specs.apollo.dev/federation/v2.10"
1010
)
1111
@link( # Enable this schema to use Apollo Connectors
12-
url: "https://specs.apollo.dev/connect/v0.1"
12+
url: "https://specs.apollo.dev/connect/v0.2"
1313
import: ["@connect", "@source"]
1414
)
1515

16-
# A @source directive defines a shared data source for multiple Connectors.
17-
# ✏️ Replace the `name` and `baseURL` of this @source with your own REST API.
16+
# ✏️ This schema is using a demo REST API as its @source. Replace the `name` and `baseURL` of it with your own REST API.
1817
@source(
1918
name: "ecomm"
2019
# A @source directive defines a shared data source for multiple Connectors.
2120
http: {
22-
baseURL: "https://ecommerce.demo-api.apollo.dev/"
21+
baseURL: "https://ecommerce.demo-api.apollo.dev/"
2322
headers: [
2423
# If your API requires headers, add them here and in your router.yaml file.
2524
# Example:

start-with-rest/supergraph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A "supergraph" is a unified GraphQL API composed of different services known as "subgraphs"
22

33
# Set the maximum Apollo Federation version that subgraphs in this supergraph can use. Lean more at 🔗 https://www.apollographql.com/docs/graphos/schema-design/connectors/directives#prerequisites
4-
federation_version: =2.10.0
4+
federation_version: =2.11.0
55
subgraphs: # Use this section to add all of the services that make up your supergraph
66
products: # Your first subgraph has been named `products`
77
routing_url: http://placeholder # This value is unused but cannot be empty

0 commit comments

Comments
 (0)