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
In order to generate valid federated schemas, you will need to annotate your both base service and the one extending it. Federated Gateway (e.g. Apollo) will then combine the individual graphs to form single federated graph.
31
+
32
+
> Base Service
33
+
34
+
```kotlin
35
+
@KeyDirective(fields =FieldSet("id"))
36
+
data classProduct(valid:Int, valdescription:String)
37
+
38
+
classProductQuery {
39
+
funproduct(id:Int): Product? {
40
+
// grabs product from a data source, might return null
41
+
}
42
+
}
43
+
44
+
// Generate the schema
45
+
val federatedTypeRegistry =FederatedTypeRegistry(emptyMap())
46
+
val config =FederatedSchemaGeneratorConfig(supportedPackages =listOf("org.example"), hooks =FederatedSchemaGeneratorHooks(federatedTypeRegistry))
47
+
val queries =listOf(TopLevelObject(ProductQuery()))
48
+
49
+
toFederatedSchema(config, queries)
50
+
```
51
+
52
+
Generates the following schema with additional federated types
53
+
54
+
```graphql
55
+
schema {
56
+
query: Query
57
+
}
58
+
59
+
#Space separated list of primary keys needed to access federated object
0 commit comments