Skip to content

Commit

Permalink
smallrye#521: add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
t1 authored and jmartisk committed Oct 3, 2022
1 parent 76c4a8b commit 72db435
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/federation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Federation

To enable support from [GraphQL Federation](https://www.apollographql.com/docs/federation), simply set the `smallrye.graphql.federation.enabled` config key to `true`.

You can add the Federation directives by using the equivalent Java annotation, e.g. to extend a `Product` entity with a `price` field, you can write a class:

```java
package org.example.price;

import org.eclipse.microprofile.graphql.Id;

import io.smallrye.graphql.api.federation.Extends;
import io.smallrye.graphql.api.federation.Key;

@Extends @Key(fields = "id")
public class Product {
@Id
private String id;

@Description("The price in cent")
private Integer price;

// getters and setters omitted
}
```

The GraphQL Schema then contains:

```graphql
type Product @extends @key(fields : ["id"]) {
id: ID
price: Int
}

union _Entity = Product

type Query {
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ nav:
- Server side features:
- Customizing JSON deserializers: 'custom-json-deserializers.md'
- Directives: 'directives.md'
- Federation: 'federation.md'
- Custom error extensions: 'custom-error-extensions.md'
- Typesafe client:
- Basic usage: 'typesafe-client-usage.md'
Expand Down

0 comments on commit 72db435

Please sign in to comment.