Skip to content

Commit 3f7e0f1

Browse files
committed
Polishing Federation section in docs
1 parent d45d31b commit 3f7e0f1

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

spring-graphql-docs/modules/ROOT/pages/federation.adoc

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
[[federation]]
22
= Federation
33

4-
Spring for GraphQL provides a small integration layer for the
5-
https://github.com/apollographql/federation-jvm[federation-jvm] library that in turn builds
6-
on GraphQL Java, and helps to initialize the `graphql.schema.GraphQLSchema` for a GraphQL
7-
Java application that is a sub-graph within a federated graph. For more details, see
8-
https://www.apollographql.com/docs/federation/[Apollo Federation] and the
9-
https://www.apollographql.com/docs/federation/subgraph-spec[Subgraph spec].
4+
Spring for GraphQL provides an integration for the
5+
https://github.com/apollographql/federation-jvm[federation-jvm] library, which uses
6+
GraphQL Java to initialize the schema of a sub-graph within a federated graph.
7+
See https://www.apollographql.com/docs/federation/[Apollo Federation] and the
8+
https://www.apollographql.com/docs/federation/subgraph-spec[Subgraph spec] for further details.
109

11-
To use the support you can declare a `FederationSchemaFactory` bean in your config, and plug
12-
it into `GraphQlSource.Builder`. In a Spring Boot application you can do this through a
13-
`GraphQlSourceBuilderCustomizer` as follows:
10+
11+
12+
[[federation.config]]
13+
== Config
14+
15+
To use the integration, declare a `FederationSchemaFactory` bean in your config, and plug
16+
it into `GraphQlSource.Builder`. For example, in a Spring Boot application:
1417

1518
[source,java,indent=0,subs="verbatim,quotes"]
1619
----
@@ -30,7 +33,7 @@ it into `GraphQlSource.Builder`. In a Spring Boot application you can do this th
3033
}
3134
----
3235

33-
Now your sub-graph schema can extend federated types:
36+
Now the schema for the sub-graph service can extend federated types:
3437

3538
[source,graphql,indent=0,subs="verbatim,quotes"]
3639
----
@@ -46,10 +49,15 @@ type Author {
4649
}
4750
----
4851

49-
To assist with resolving federated types as part of an
50-
https://www.apollographql.com/docs/federation/subgraph-spec/#understanding-query_entities[_entities]
51-
query, you can use `@EntityMapping` methods side by side with `@SchemaMapping` methods
52-
for the data that the subgraph application owns. For example:
52+
53+
[[federation.entity-mapping]]
54+
== `@EntityMapping`
55+
56+
To resolve federated types in response to the
57+
https://www.apollographql.com/docs/federation/subgraph-spec/#understanding-query_entities[_entities query],
58+
you can use `@EntityMapping` methods along with `@SchemaMapping` methods for types under the entity.
59+
60+
For example:
5361

5462
[source,java,indent=0,subs="verbatim,quotes"]
5563
----
@@ -69,8 +77,14 @@ for the data that the subgraph application owns. For example:
6977
}
7078
----
7179

72-
The `@Argument` method parameters is resolved from the "representation"input map for the entity.
73-
You can also inject the full `Map<String, Object>`. The below shows all supported arguments:
80+
The `@Argument` method parameters is resolved from the "representation" input map for the entity.
81+
You can also inject the full "representation" input `Map`.
82+
83+
84+
[[federation.entity-mapping.signature]]
85+
=== Method Signature
86+
87+
Entity mapping methods support the following arguments:
7488

7589
[cols="1,2"]
7690
|===
@@ -110,6 +124,10 @@ You can also inject the full `Map<String, Object>`. The below shows all supporte
110124

111125
`@EntityMapping` methods can return `Mono`, `CompletableFuture`, `Callable`, or the actual entity.
112126

127+
128+
[[federation.entity-mapping.exception-handling]]
129+
=== Exception Handling
130+
113131
You can use `@GraphQlExceptionHandler` methods to map exceptions from `@EntityMapping`
114132
methods to ``GraphQLError``'s. The errors will be included in the response of the
115133
"_entities" query. Exception handler methods can be in the same controller or in an

0 commit comments

Comments
 (0)