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
[**Apollo Federation**](https://www.apollographql.com/docs/federation/) is a powerful, open architecture that helps you create a **unified supergraph** that combines multiple GraphQL APIs.
9
-
`graphql-java-support` provides Apollo Federation support for building subgraphs in the `graphql-java` ecosystem. Individual subgraphs can be run independently of each other but can also specify
10
+
`federation-graphql-java-support` provides Apollo Federation support for building subgraphs in the `graphql-java` ecosystem. Individual subgraphs can be run independently of each other but can also specify
10
11
relationships to the other subgraphs by using Federated directives. See [Apollo Federation documentation](https://www.apollographql.com/docs/federation/) for details.
11
12
12
13
```mermaid
@@ -18,180 +19,32 @@ graph BT;
18
19
gateway --- serviceA & serviceB & serviceC;
19
20
```
20
21
21
-
`graphql-java-support` is built on top of `graphql-java` and provides transformation logic to make your GraphQL schemas Federation compatible. `SchemaTransformer` adds common Federation
22
+
## Modules
23
+
24
+
### Federation JVM Support
25
+
26
+
`federation-graphql-java-support` is built on top of `graphql-java` and provides transformation logic to make your GraphQL schemas Federation compatible. `SchemaTransformer` adds common Federation
22
27
type definitions (e.g. `_Any` scalar, `_Entity` union, Federation directives, etc) and allows you to easily specify your Federated entity resolvers.
23
28
24
29
This project also provides a set of Federation aware instrumentations:
25
30
26
31
*`CacheControlInstrumentation` - instrumentation that computes a max age for an operation based on `@cacheControl` directives
27
32
*`FederatedTracingInstrumentation` - instrumentation that generates trace information for federated operations
28
33
29
-
## Installation
30
-
31
-
Federation JVM libraries are published to [Maven Central](https://search.maven.org/search?q=g:com.apollographql.federation%20AND%20a:federation-graphql-java-support).
32
-
Using a JVM dependency manager, link `graphql-java-support` to your project.
Additional documentation on the Apollo Federation and JVM usage can be found on the [Apollo Documentation Portal](https://www.apollographql.com/docs/federation/).
53
-
54
-
Federation JVM example integrations
34
+
See module [README](graphql-java-support/README.md) for details.
### Subscription HTTP Callback Support for Spring GraphQL
59
37
60
-
### Creating Federated Schemas
38
+
GraphQL subscriptions enable clients to receive continual, real-time updates whenever new data becomes available. Unlike
39
+
queries and mutations, subscriptions are long-lasting. This means a client can receive multiple updates from a single subscription.
61
40
62
-
Using `graphql-java` (or [your](https://docs.spring.io/spring-graphql/docs/current/reference/html/)[framework](https://netflix.github.io/dgs/) of [choice](https://www.graphql-java-kickstart.com/spring-boot/))
63
-
we first need to create a GraphQL schema.
41
+
[Spring GraphQL](https://docs.spring.io/spring-graphql/reference/) provides out of box support for GraphQL subscriptions
42
+
over WebSockets using [graphql-transport-ws](https://github.com/enisdenjo/graphql-ws) protocol. This library adds support
43
+
for subscriptions using [Apollo HTTP callback protocol](https://www.apollographql.com/docs/router/executing-operations/subscription-callback-protocol).
64
44
65
-
Assuming there is already a subgraph that defines a base `Product` type
We can then generate Federation compatible schema using schema transformer. In order to be able to resolve the federated `Product` type, we need to provide `TypeResolver` to resolve [`_Entity`](https://www.apollographql.com/docs/federation/federation-spec/#union-_entity)
106
-
union type and a `DataFetcher` to resolve [`_entities`](https://www.apollographql.com/docs/federation/federation-spec/#query_entities) query.
This will generate a schema with additional federated info.
136
-
137
-
```graphql
138
-
union_Entity = Product
139
-
140
-
typeProduct@extends@key(fields : "id") {
141
-
id: ID!@external
142
-
reviews: [Review!]!
143
-
}
144
-
145
-
typeQuery {
146
-
_entities(representations: [_Any!]!): [_Entity]!
147
-
_service: _Service
148
-
}
149
-
150
-
typeReview {
151
-
id: ID!
152
-
rating: Int!
153
-
text: String
154
-
}
155
-
156
-
type_Service {
157
-
sdl: String!
158
-
}
159
-
160
-
scalar_Any
161
-
162
-
scalar_FieldSet
163
-
```
164
-
165
-
### Instrumentation
166
-
167
-
#### Federated Tracing
168
-
169
-
[Tracing your GraphQL queries](https://www.apollographql.com/docs/federation/metrics) can provide you detailed insights into your GraphQL layer's performance and usage. Single federated query may
170
-
be executed against multiple GraphQL servers. Apollo Gateway provides ability to aggregate trace data generated by the subgraphs calls and then send them to [Apollo Studio](https://www.apollographql.com/docs/studio/)
171
-
172
-
To make your server generate performance traces and return them along with responses to the Apollo Gateway, install the `FederatedTracingInstrumentation` into your `GraphQL` object:
**By default, all requests will be traced.** In order to skip dev requests and only trace requests that come from the Apollo Gateway, you should populate tracing information in the `GraphQLContext` map.
181
-
This will ensure that only requests with `apollo-federation-include-trace=ftv1` header value will be traced.
0 commit comments