Skip to content

Commit ef9567f

Browse files
Update federation.md
1 parent ae7f1c2 commit ef9567f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

content/graphql/federation.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@
44

55
To quote the [Apollo docs](https://blog.apollographql.com/apollo-federation-f260cf525d21), Federation is designed with these core principles:
66

7-
- **Building a graph should be declarative.** With federation, you compose a graph declaratively from within your schema instead of writing imperative schema stitching code.
8-
- **Code should be separated by concern, not by types.** Often no single team controls every aspect of an important type like a User or Product, so the definition of these types should be distributed across teams and codebases, rather than centralized.
9-
- **The graph should be simple for clients to consume.** Together, federated services can form a complete, product-focused graph that accurately reflects how it’s being consumed on the client.
10-
- **It’s just GraphQL, using only spec-compliant features of the language.** Any language, not just JavaScript, can implement federation.
7+
- Building a graph should be **declarative.** With federation, you compose a graph declaratively from within your schema instead of writing imperative schema stitching code.
8+
- Code should be separated by **concern**, not by types. Often no single team controls every aspect of an important type like a User or Product, so the definition of these types should be distributed across teams and codebases, rather than centralized.
9+
- The graph should be simple for clients to consume. Together, federated services can form a complete, product-focused graph that accurately reflects how it’s being consumed on the client.
10+
- It’s just **GraphQL**, using only spec-compliant features of the language. Any language, not just JavaScript, can implement federation.
1111

12-
> warn **Note** Apollo Federation currently does not support subscriptions, and only the "Schema first" approach is currently supported due to limitations with the decorators not yet supporting GraphQL directives<sup>[1](https://github.com/MichalLytek/type-graphql/issues/351)</sup>
12+
> warning **Note** Apollo Federation currently does not support subscriptions, and only the schema-first approach is currently supported due to limitations with the decorators not yet supporting GraphQL directives<sup>[1](https://github.com/MichalLytek/type-graphql/issues/351)</sup>
1313
1414
In the next example, we'll set up a demo application with a gateway and two federated endpoints: a user- and posts service.
1515

1616
#### Federated example: Users
1717

18-
First install the optional dependency for federation: `npm install --save @apollo/federation`.
18+
First install the optional dependency for federation:
19+
20+
```bash
21+
$ npm install --save @apollo/federation`
22+
```
1923

2024
The User service has a simple schema. Note the `@key` directive, it tells the Apollo query planner that a particular instance of User can be fetched if you have its `id`. Also note that we extend the Query type.
2125

22-
```java
26+
```graphql
2327
type User @key(fields: "id") {
2428
id: ID!
2529
name: String!
@@ -74,7 +78,7 @@ export class AppModule {}
7478
7579
The Posts service references the User type in its schema by marking it with the `extend` keyword. It also adds one property to the User type. Note the `@key` directive used for matching instances of User, and the `@external` directive indicating that the `id` field is managed elsewhere.
7680
77-
```java
81+
```graphql
7882
type Post @key(fields: "id") {
7983
id: ID!
8084
title: String!
@@ -162,7 +166,7 @@ import { GraphQLGatewayModule } from "@nestjs/graphql";
162166
export class AppModule {}
163167
```
164168
165-
> warn **Warning** Apollo recommends that you don't rely on the service discovery in a production environment but use their [Graph Manager](https://www.apollographql.com/docs/graph-manager/federation/) instead.
169+
> info **Hint** Apollo recommends that you don't rely on the service discovery in a production environment but use their [Graph Manager](https://www.apollographql.com/docs/graph-manager/federation/) instead.
166170
167171
#### Sharing context
168172

0 commit comments

Comments
 (0)