Odyssey

Federated subscriptions with TypeScript & Apollo Server

Course overview and setupFederated subscriptionsSetting up subscriptionsSubscriptions over HTTP callbacksPubSub and resolversThe Subscription resolverReturning subscription dataUsing withFilterSynchronizing graph-wide updates
9. Synchronizing graph-wide updates
9m

Overview

Now that our subscription is working (and has been filtered), let's broaden our focus. So far, we've been working with just a single subgraph: so, do we get any actually benefit from using a federated graph, rather than a single GraphQL server? Let's dive in!

In this lesson, we will:

  • Talk about the subscription process in a federated graph
  • Look at operations that involve fields from multiple subgraphs
  • "Subscribe" to updates across the graph by using fields from a different subgraph

Updates from across the graph

Let's review what our router's doing when we send it a subscription operation. Recall that the router first devises its query plan—the set of instructions it follows to resolve the query. This can involve making multiple smaller requests to multiple different subgraphs, but so far we see that our router's sending a request to just one: the messages subgraph.

So why don't we just send our client operations directly to the messages subgraph? After all, the router looks like just another stop on the way to data.

Well, it's important to remember that when we use the router to execute operations against our federated graph, we get the benefit of our entire API at our fingertips. So we might instead build a subscription operation to query data from across our graph: we'll subscribe to one single aspect of our schema (each message as it's added to a conversation), but we can bring other data from across our other subgraphs along for the ride.

A diagram showing the router retrieving subscription data from one subgraph, and additional data from others

Here's one way we might build out our subscription operation to include fields from other subgraphs.

subscription SubscribeToMessagesInConversation($messageInConversationId: ID!) {
messageInConversation(id: $messageInConversationId) {
text
sentTime
sentTo {
id
name
profileDescription
}
sentFrom {
id
name
}
}
}

We've modified our operation to include the additional Message type fields sentTo and sentFrom. Both of these fields return a User type, from which we can select additional subfields.

But if we jump into our messages subgraph schema, we'll find that most of these fields (name, profileDescription) are not resolved here; they're actually the responsibility of our accounts subgraph. Because the User type is an entity, it has fields in different subgraphs.

An entity is an object type whose fields can be contributed by different subgraphs. Compare the two different User definitions shown below:

# User definition in MESSAGES
type User @key(fields: "id") {
id: ID! # 🔑 Key field which allows us to associate objects between messages & accounts
}
# User definition in ACCOUNTS
type User @key(fields: "id") {
id: ID! # 🔑 Key field which allows us to associate objects between messages & accounts
"The user's first and last name"
name: String!
"The user's profile bio description, will be shown in the listing"
profileDescription: String!
"The last recorded activity timestamp of the user"
lastActiveTime: String
"Whether or not a user is logged in"
isLoggedIn: Boolean!
}

We get many more fields about a User from the accounts subgraph, but importantly, both messages and accounts can use the same User type. This is useful in the context of messages, where we store the id of the user that sent the message! When composed together, these two subgraph schemas (and two User type definitions) allow us to build robust queries that take advantage of all the possible User fields across our graph.

If we revisit this updated operation, we can see how different fields will be provided by different subgraphs.

subscription SubscribeToMessagesInConversation(
$messageInConversationId: ID!
) {
messageInConversation(id: $messageInConversationId) {
text
sentTime
sentTo {
id
name # 👤 Provided by the accounts subgraph
profileDescription # 👤 Provided by the accounts subgraph
}
sentFrom {
id
name # 👤 Provided by the accounts subgraph
}
}
}

Want to learn more about entities and how they're built? Check out the Odyssey course Federation with TypeScript & Apollo to go deeper.

If we ran this new subscription operation, the router would have two stops to make for every new event: it would receive the details of the new message submitted, and could provide the values right away for the text and sentTime fields. But to provide the data for sentFrom and sentTo, it would need to take both user IDs and make an additional request to accounts. Once all the details are collected, the router would bundle the data together and return it to the client.

A diagram showing where each field is fetched from, on every new message event

This is pretty cool, because it means that every time our subscription picks up a new message, the router makes sure that we request the data for each user involved in the conversation.

But—there's a flipside. Do we want to re-request each user's id, name, and sometimes even profileDescription each time we get a new message? Well... probably not. Those fields are unlikely to change frequently enough to warrant refreshing the data with each new message event. Instead, we might want to focus on other fields in our graph that do change more frequently.

Let's explore a better use case for our subscription operation next.

Adding the isOnline field

Rather than filling up our subscription operation with all sorts of static fields from across our graph, we'll keep it focused.

We want this operation to be responsible for notifying us of each new message as soon as it's sent and saved in the database. Focusing on the "realtime" nature of our messages subgraph, we might also be interested to know whether our message recipient is online. This is a status that can change from moment to moment, which makes it a good candidate to include in our operation.

subscription SubscribeToMessagesInConversation($messageInConversationId: ID!) {
messageInConversation(id: $messageInConversationId) {
text
sentTime
sentTo {
id
isOnline
}
}
}

There's just one problem: our User type doesn't actually have an isOnline field that we can use. Let's add one!

Jump into your messages subgraph, and open up src/schema.graphql. Let's add this field to our User type, with a return type of non-nullable Boolean.

messages/src/schema.graphql
type User @key(fields: "id") {
id: ID!
"The status indicating whether a user is online"
isOnline: Boolean!
}

The big question is: what determines whether someone is online?

extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key"])
type Query {
"Retrieve all conversations for the logged-in user"
conversations: [Conversation]
"Retrieves your conversation with a given recipient"
conversation(recipientId: ID!): Conversation
}
type Mutation {
"Start a new conversation with a particular user"
createConversation(recipientId: ID!): Conversation
"Submit a new message to a specified conversation"
sendMessage(message: NewMessageInput!): Message
}
type Subscription {
"Subscribe to new messages in a conversation"
messageInConversation(id: ID!): Message
}
type Conversation {
id: ID!
"The messages belonging to the conversation"
messages: [Message]
"The timestamp from when the conversation was created"
createdAt: String!
}
type Message {
id: ID!
"The text content of the message"
text: String!
"The user that sent the message"
sentFrom: User!
"The user the message was sent to"
sentTo: User!
"The timestamp of when the message was sent"
sentTime: String
}
input NewMessageInput {
"The text content of the message"
text: String!
"The ID of the conversation"
conversationId: String!
}
type User @key(fields: "id") {
id: ID!
"The status indicating whether a user is online"
isOnline: Boolean!
}

Considerations for isOnline status

When deciding whether someone is "online", we'll use two factors: whether they're logged in and whether they have been active within some recent time period.

There are two fields that can help us here: isLoggedIn and lastActiveTime. Both of these fields exist on the User type, but they exist in the accounts subgraph! And because the isOnline field is relevant to our chat feature, it makes sense to keep it within the messages subgraph.

# User definition in MESSAGES
type User @key(fields: "id") {
id: ID!
"The status indicating whether a user is online"
isOnline: Boolean! # ⬅️ How do we determine true/false?
}
# User definition in ACCOUNTS
type User @key(fields: "id") {
id: ID!
# ... other fields
"The last recorded activity timestamp of the user"
lastActiveTime: String
"Whether or not a user is logged in"
isLoggedIn: Boolean!
}

So how exactly can we use lastActiveTime and isLoggedIn (provided by a completely separate subgraph) to determine the value of isOnline? Directives to the rescue!

@requires and @external

Federation directives are special instructions we can include in our schema to tell the router to do something specific. We've already seen one of these directives, @key, which is used to indicate the primary key(s) that we can use when referring to an entity instance across our graph.

There are two additional directives that we'll put to work in our messages subgraph: @requires and @external.

Let's scroll to the top of our schema.graphql file and add them to our federation import.

messages/src/schema.graphql
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.8"
import: ["@key", "@requires", "@external"]
)

Let's walk through what both of these directives can do for us.

@requires

The @requires directive is used to indicate that the field requires one or more values from other fields before it can return its own data. It tells the router that a particular field cannot return a value until it has the values of another field (or fields) first.

Let's take a look at the syntax by applying it to our isOnline field.

type User @key(fields: "id") {
id: ID!
isOnline: Boolean! @requires
}

After @requires, we pass a set of parentheses (()) where we include the names of the fields that are "required". In our case, we want to first know a user's lastActiveTime and isLoggedIn field values before we make any determination about whether they're online or not. We'll pass these field names as a single string (separated with a space) to a property called fields.

type User @key(fields: "id") {
id: ID!
isOnline: Boolean! @requires(fields: "lastActiveTime isLoggedIn")
}

That's it for @requires—but we have a few more schema updates to make.

Our messages subgraph still has no idea what these required fields are, or where they come from. This is where @external shines!

@external

We use the @external directive when we need a subgraph schema to reference a field it's not actually responsible for resolving. Our current situation is a great example of this: one of our fields requires the values of two other fields before it can return data. But those fields don't exist within the messages subgraph; they're external fields.

To fix this problem, and keep our subgraph from getting confused, we'll update our User definition with both of these required fields. They should be exactly the same as they're defined in the accounts subgraph, with one difference: we'll tack on the @external directive to both.

type User @key(fields: "id") {
id: ID!
isOnline: Boolean! @requires(fields: "lastActiveTime isLoggedIn")
"The last recorded activity timestamp of the user"
lastActiveTime: String @external
"Whether or not a user is logged in"
isLoggedIn: Boolean! @external
}
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.8"
import: ["@key", "@requires", "@external"]
)
type Query {
"Retrieve all conversations for the logged-in user"
conversations: [Conversation]
"Retrieves your conversation with a given recipient"
conversation(recipientId: ID!): Conversation
}
type Mutation {
"Initiate a new conversation with a particular user"
createConversation(recipientId: ID!): Conversation
"Submit a new message to a specified conversation"
sendMessage(message: NewMessageInput!): Message
}
type Subscription {
"Subscribe to new messages in a conversation"
messageInConversation(id: ID!): Message
}
type Conversation {
id: ID!
"The messages belonging to the conversation"
messages: [Message]
"The timestamp from when the conversation was created"
createdAt: String!
}
type Message {
id: ID!
"The text content of the message"
text: String!
"The user that sent the message"
sentFrom: User!
"The user the message was sent to"
sentTo: User!
"The timestamp of when the message was sent"
sentTime: String
}
input NewMessageInput {
"The text content of the message"
text: String!
"The ID of the conversation"
conversationId: String!
}
type User @key(fields: "id") {
id: ID!
isOnline: Boolean! @requires(fields: "lastActiveTime isLoggedIn")
"The last recorded activity timestamp of the user"
lastActiveTime: String @external
"Whether or not a user is logged in"
isLoggedIn: Boolean! @external
}

Walking through the operation

So how exactly does this change the way the router resolves our operation? Let's walk through it step-by-step.

Subscription operation
subscription SubscribeToMessagesInConversation($messageInConversationId: ID!) {
messageInConversation(id: $messageInConversationId) {
text
sentTime
sentTo {
id
isOnline
}
}
}

To resolve this operation, the router establishes the subscription with messages via the Subscription.messageInConversation field. With every new message event, it returns the message's text and sentTime fields.

A diagram showing the query's entrypoint provided by the messages subgraph, along with the first two fields immediately available on the returned message

But when it gets to the sentTo field, the router sees that there's additional information requested; we want to know whether the recipient of the message is online. In order to fetch this field from messages, the router sees that it first needs to go and fetch the lastActiveTime and isLoggedIn fields from the accounts subgraph! (The isOnline field, after all, requires them to do its job!)

A diagram showing how resolving the sentTo user's isOnline field first requires values from accounts

The sentTo field returns a User type, and the router uses the id (the User type's primary key) to make a request to the accounts subgraph for the same user's lastActiveTime and isLoggedIn values.

A diagram showing the User representation being sent to the accounts subgraph to retrieve additional fields

The accounts subgraph uses that provided id to look up the corresponding User, and it resolves the values for lastActiveTime and isLoggedIn, returning them to the router.

A diagram showing the accounts subgraph using the entity representation to find the right user object and return a new representation

Now the router has the required values in hand! It returns to the messages subgraph, passing along not just the User type's id field, but lastActiveTime and isLoggedIn as well. (This is called the entity representation, the object that the router uses to associate objects between subgraphs.)

A diagram showing the retrieved values now available to the messages subgraph, and can be used in the isOnline resolver

Now the messages subgraph has all the data it needs to resolve isOnline. Inside the isOnline resolver, we can pluck off the lastActiveTime and isLoggedIn fields and write the logic to determine conclusively whether a user should appear as online or not.

When a query includes entity fields (such as the fields we've included from the User type), the router often needs to send smaller requests to each subgraph that provides them. All the while, the router needs to ensure that each subgraph it requests for data knows which instance the query concerns.

This is where an entity's key field (or fields) comes in handy. In our example, we used a User type's id field: this is because both the accounts and the messages subgraph determine which user is which through the id field.

When the router requests data about an entity from one subgraph, it uses an entity representation. This is an object that includes the minimum required information for that subgraph to determine which instance the router is asking about. In a basic scenario, this entity representation might contain just two fields: the __typename for the specific GraphQL type, and the entity's primary key, such as id. Using this data, a subgraph could then determine which object it needed to populate fields for.

{ __typename: "User", id: "wardy" }

When we use federation directives, such as @requires and @external, the entity representation has the potential to grow a little bit. As we saw in our query plan walkthrough, the isOnline field provided by the messages subgraph first requires the lastActiveTime and isLoggedIn fields. This means the router must first fetch these fields before sending the entity representation to the messages subgraph. And this time, it knows that it needs to include more than __typename and id: the messages subgraph has stated loud and clear that in order to resolve isOnline, it needs those values for lastActiveTime and isLoggedIn as well!

So in reality, our entity representation would look more like the following code block.

{ __typename: "User", id: "wardy", "lastActiveTime": "TIMESTAMP", "isLoggedIn": false }

Still curious about entity representations? Go deeper in Federation with TypeScript & Apollo.

Now that we've seen how we get access to lastActiveTime and isLoggedIn, let's use those values in the isOnline resolver to return true or false!

Updating resolvers

In the resolvers/User.ts file, make some space for a new resolver function called isOnline.

resolvers/User.ts
User: {
__resolveReference: async ({ id, ...attributes }, { dataSources }) => {
const user = await dataSources.db.getUserDetails(id)
return { ...attributes, ...user, id: user.username }
},
isOnline: () => {}
}

We'll start by destructuring the first positional argument, parent, for those two fields that we required from the accounts subgraph: lastActiveTime and isLoggedIn.

isOnline: ({ lastActiveTime, isLoggedIn }) => {
// TODO
},

Next we'll paste in some logic. This checks whether the user is logged in AND if they've been active in the last five minutes.

const now = Date.now();
const lastActiveDate = new Date(lastActiveTime).getTime();
const difference = now - lastActiveDate;
if (isLoggedIn && difference < 300000) {
return true;
}
return false;

Error: Binding element 'lastActiveTime' (or isLoggedIn) implicitly has an 'any' type.

How to fix it: Try restarting the TypeScript server. You can do this in VSCode by opening the command palette (Command + P) and searching for the command "TypeScript: Restart TS Server".

Still having trouble? Visit the Odyssey forums to get help.

import { Resolvers } from "../__generated__/resolvers-types";
export const User: Resolvers = {
User: {
__resolveReference: async ({ id, ...attributes }, { dataSources }) => {
const user = await dataSources.db.getUserDetails(id)
return { ...attributes, ...user, id: user.username }
},
isOnline: ({ lastActiveTime, isLoggedIn }) => {
const now = Date.now();
const lastActiveDate = new Date(lastActiveTime).getTime();
const difference = now - lastActiveDate;
if (isLoggedIn && difference < 300000) {
return true;
}
return false;
},
}
}

Try it out!

Let's see our subscription in action: this time, with data coming from two parts of our graph. Open up http://localhost:4000 where our rover dev process should still be running the local router.

We'll set up our subscription to the same conversation, and send a message.

Step 1: Start the subscription

Open up a new tab and paste in the following subscription operation:

subscription SubscribeToMessagesInConversation($messageInConversationId: ID!) {
messageInConversation(id: $messageInConversationId) {
text
sentTime
sentTo {
id
isOnline
}
}
}

And in the Variables tab:

Variables
{
"messageInConversationId": "wardy-eves-chat"
}

Also, make sure that your Headers tab reflects the following:

Headers
Authorization: Bearer eves

Step 2: Send a message

Next let's send a message to that conversation. You know the drill! Open up a new tab, add the operation from your Operation Collection, or paste the operation below.

mutation SendMessageToConversationIncludeOnline($message: NewMessageInput!) {
sendMessage(message: $message) {
text
sentTo {
id
name
isOnline
}
}
}

And in the Variables panel:

Variables
{
"message": {
"text": "Hey there, thanks so much for booking!",
"conversationId": "wardy-eves-chat"
}
}

Make sure that your Headers tab includes the values specified previously. Submit the operation! We should see the new subscription event, along with the usual mutation response.

Step 3: Change the recipient's online status!

Now let's toggle the online status of our recipient. Open up a new tab; this time we'll "log in" as our recipient, wardy.

Add the following operation:

Toggle the user's logged in status
mutation ToggleUserLoggedIn {
changeLoggedInStatus {
time
success
message
}
}

And in the Headers tab, make sure that your Authorization header now specifies wardy. (We want to log the recipient of our message in/out!)

Headers
Authorization: Bearer wardy

Step 4: Send another message, toggle status, and repeat!

Return to the tab where you've built the SendMessageToConversationIncludeOnline operation—and send another message! (Here, you should be authorized as eves.)

This time, you should see in the Subscriptions box that the recipient's isOnline status has changed! Jump back to the tab with ToggleUserLoggedIn and toggle their status once more. When you go back to send another message, you should see that their status has changed again!

http://localhost:4000

A screenshot of Sandbox, the user was toggled online

With every new message we send or receive, we're getting a fresh update of the user's "online" status; all through using schema directives, and the power of the router!

Practice

Use the following code snippets to answer the multiple choice question.

Example reviews subgraph
type Subscription {
reviewOnListing(id: ID!): Review
}
type Review {
review: String!
rating: Int!
author: User!
listing: Listing!
}
# Other fields exist in the `listings` subgraph
type Listing @key(fields: "id") {
id: ID!
}
# Other fields exist in the `accounts` subgraph
type User @key(fields: "id") {
id: ID!
}
An example operation
subscription SubscribeToNewReviews($reviewOnListing: ID!) {
reviewOnListing(id: $reviewOnListingId) {
review
rating
author {
id
name
}
listing {
title
}
}
}
Which of the following describes how the router would handle resolving the SubscribeToNewReviews operation with each new subscription event?
Code Challenge!

Add a new field to the Mission type called readyToLaunch, a non-null Boolean. This field requires the mission's availableFunds, a nullable Int type defined in a separate subgraph. Make sure to add descriptions for each field!

Code Challenge!

Implement the resolver function for Mission.readyToLaunch. Use the availableFunds field value to return true if the amount exceeds 2000 and false if not.

Key takeaways

  • Subscription operations can include not only the single "realtime" field that frequently changes, but other fields from across our graph as well.
  • Each time a new subscription event occurs, the router will refetch the data for all fields included in the operation, and return it all at once.
  • We can use federation directives, such as @requires and @external, to indicate that one entity field requires the value (or values) of another field before it can return data.

Journey's end

And with that, you've made it to the end! You've implemented federated subscriptions from start to finish, moving from development to production without missing a beat. Excellent job!

That's not all though: we've barely scratched the surface of the tooling available to you when you run a graph through GraphOS Studio and the router. Keep an eye out for the second part in this series, Subscription Observability, coming soon on Odyssey! Thanks for joining us in this one—we're looking forward to our next journey together.

Previous

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.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              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.

              graph

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

              GraphQL server

              A server that contains a GraphQL schema and can resolve client-requested operations that are executed against that schema.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              graph

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

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              graph

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

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              query plan

              A strategy for executing an incoming operation efficiently. A query plan divides a single incoming operation into one or more operations that are each resolvable by a single subgraph.

              subgraphs

              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.

              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.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              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.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              query

              A request for specific data from a GraphQL server. Clients define the structure of the response, enabling precise and efficient data retrieval.

              graph

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

              subgraphs

              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.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              subgraphs

              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.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              subgraph schema

              A schema for a subgraph server. A subgraph schema must be compliant with the GraphQL and Apollo Federation specs to be composed into a supergraph.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              subgraphs

              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.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              object type

              A type in a GraphQL schema that has one or more fields. User is an object type in the following example:

              type User {
              name: String!
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              subgraphs

              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.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              subgraph schemas

              A schema for a subgraph server. A subgraph schema must be compliant with the GraphQL and Apollo Federation specs to be composed into a supergraph.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              graph

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

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              subgraphs

              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.

              entities

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              Odyssey

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

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              graph

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

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              graph

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

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              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.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              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.

              Directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              graph

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

              directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              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.

              directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              directive

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              directive

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              subgraph schema

              A schema for a subgraph server. A subgraph schema must be compliant with the GraphQL and Apollo Federation specs to be composed into a supergraph.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              directive

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              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.

              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.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              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.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              subgraphs

              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.

              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.

              resolver

              A function that populates data for a particular field in a GraphQL schema. For example:

              const resolvers = {
              Query: {
              author(root, args, context, info) {
              return find(authors, { id: args.id });
              },
              },
              };
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              query

              A request for specific data from a GraphQL server. Clients define the structure of the response, enabling precise and efficient data retrieval.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              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.

              query

              A request for specific data from a GraphQL server. Clients define the structure of the response, enabling precise and efficient data retrieval.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              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.

              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.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              GraphQL

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

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              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.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              query plan

              A strategy for executing an incoming operation efficiently. A query plan divides a single incoming operation into one or more operations that are each resolvable by a single subgraph.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              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.

              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.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              resolver

              A function that populates data for a particular field in a GraphQL schema. For example:

              const resolvers = {
              Query: {
              author(root, args, context, info) {
              return find(authors, { id: args.id });
              },
              },
              };
              resolver

              A function that populates data for a particular field in a GraphQL schema. For example:

              const resolvers = {
              Query: {
              author(root, args, context, info) {
              return find(authors, { id: args.id });
              },
              },
              };
              argument

              A key-value pair associated with a particular schema field that lets operations pass data to that field's resolver.

              Argument values can be hardcoded as literal values (shown below for clarity) or provided via GraphQL variables (recommended).

              query GetHuman {
              human(id: "200") {
              name
              height(unit: "meters")
              }
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              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.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              graph

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

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              mutation

              A GraphQL operation that modifies data on the server. It allows clients to perform create, update, or delete operations, altering the underlying data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              Subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              graph

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

              subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              directives

              A GraphQL annotation for a schema or operation that customizes request execution. Prefixed with @ and may include arguments. For example, the @lowerCase directive below can define logic to return the username field in lowercase:

              type User {
              username: String! @lowerCase
              }
              entity

              An object type of Apollo Federation that can be fetched with one or more unique keys. Can resolve its fields from multiple data sources in a federated graph.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              subscriptions

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              graph

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

              GraphOS Studio

              The web interface for GraphOS, which provides graph, variant, and organization management, metrics visualization, schema pipeline tools and more.

              router

              The single access point for a federated GraphQL architecture. It receives incoming operations and intelligently routes them across component services before returning a unified response.

              Subscription

              A long-lived, real-time GraphQL operation that enables real-time communication by allowing clients to receive data updates from the server when specific events or changes occur.

              Odyssey

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

              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