You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/graphql/federation.md
+47-2Lines changed: 47 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -743,7 +743,7 @@ export class AppModule {}
743
743
744
744
To quote the [Apollo docs](https://www.apollographql.com/docs/federation/federation-2/new-in-federation-2), Federation 2 improves developer experience from the original Apollo Federation (called Federation 1 in this doc), which is backward compatible with most original supergraphs.
745
745
746
-
> warning **Warning** Mercurius currently doesn't fully support Federation 2. You can see the list of libraries that support Federation 2 [here](https://www.apollographql.com/docs/federation/supported-subgraphs#javascript--typescript).
746
+
> warning **Warning** Mercurius doesn't fully support Federation 2. You can see the list of libraries that support Federation 2 [here](https://www.apollographql.com/docs/federation/supported-subgraphs#javascript--typescript).
747
747
748
748
In the following sections, we'll upgrade the previous example to Federation 2.
749
749
@@ -821,4 +821,49 @@ type Query {
821
821
822
822
#### Code first
823
823
824
-
TBD
824
+
Sincewedon'textend `User` entityanymore, wecansimplyremove `extends` and `external` directivesfrom `User`.
825
+
826
+
```ts
827
+
import { Directive, ObjectType, Field, ID } from '@nestjs/graphql';
828
+
import { Post } from './post.entity';
829
+
830
+
@ObjectType()
831
+
@Directive('@key(fields: "id")')
832
+
exportclassUser {
833
+
@Field((type) => ID)
834
+
id: number;
835
+
836
+
@Field((type) => [Post])
837
+
posts?: Post[];
838
+
}
839
+
```
840
+
841
+
Also, similar to User service, we need to specify `GraphQLModule` to use Federation 2.
0 commit comments