Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/maven/version.smallrye-context-pr…
Browse files Browse the repository at this point in the history
…opagation-2.0.0
  • Loading branch information
phillip-kruger authored Sep 29, 2022
2 parents a0f5c59 + 41ab806 commit 7aff796
Show file tree
Hide file tree
Showing 39 changed files with 488 additions and 668 deletions.
2 changes: 2 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
:graphql-over-http: https://github.com/graphql/graphql-over-http
:subscriptions-transport-ws: https://github.com/apollographql/subscriptions-transport-ws
:graphql-ws: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md
:graphql-federation: https://www.apollographql.com/docs/federation

image:https://github.com/smallrye/smallrye-graphql/workflows/SmallRye%20Build/badge.svg?branch=main[link=https://github.com/smallrye/smallrye-graphql/actions?query=workflow%3A%22SmallRye+Build%22]
image:https://sonarcloud.io/api/project_badges/measure?project=smallrye_smallrye-graphql&metric=alert_status["Quality Gate Status", link="https://sonarcloud.io/dashboard?id=smallrye_smallrye-graphql"]
Expand All @@ -16,6 +17,7 @@ SmallRye GraphQL is an implementation of
- {graphql-over-http}[GraphQL over HTTP].
- {graphql-ws}[GraphQL over WebSocket].
- {subscriptions-transport-ws}[Subscriptions transport ws] (old).
- {graphql-federation}[GraphQL Federation]

== Instructions

Expand Down
60 changes: 60 additions & 0 deletions docs/federation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Federation

To enable support for [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
}
```

And a normal query method that takes the `key` fields as a parameter and returns the requested type:

```java
package org.example.price;

import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Query;

@GraphQLApi
public class Prices {
@Query
public Product product(@Id String id) {
return ...;
}
}
```

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!
product(id: ID): Product
}
```
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
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<version.jakarta-annotation>2.1.1</version.jakarta-annotation>
<version.jakarta.servlet>5.0.0</version.jakarta.servlet>
<version.jakarta.websocket>2.0.0</version.jakarta.websocket>
<version.graphql-java-federation>2.0.8</version.graphql-java-federation>
<version.graphql-java>19.2</version.graphql-java>
<verison.io.micrometer>1.9.3</verison.io.micrometer>
<version.vertx>4.3.3</version.vertx>
Expand Down Expand Up @@ -247,6 +248,11 @@
<artifactId>graphql-java</artifactId>
<version>${version.graphql-java}</version>
</dependency>
<dependency>
<groupId>com.apollographql.federation</groupId>
<artifactId>federation-graphql-java-support</artifactId>
<version>${version.graphql-java-federation}</version>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.smallrye.graphql.federation.api;
package io.smallrye.graphql.api.federation;

import static io.smallrye.graphql.api.DirectiveLocation.INTERFACE;
import static io.smallrye.graphql.api.DirectiveLocation.OBJECT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.smallrye.graphql.federation.api;
package io.smallrye.graphql.api.federation;

import static io.smallrye.graphql.api.DirectiveLocation.FIELD_DEFINITION;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.smallrye.graphql.federation.api;
package io.smallrye.graphql.api.federation;

import static io.smallrye.graphql.api.DirectiveLocation.INTERFACE;
import static io.smallrye.graphql.api.DirectiveLocation.OBJECT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.smallrye.graphql.federation.api;
package io.smallrye.graphql.api.federation;

import static io.smallrye.graphql.api.DirectiveLocation.FIELD_DEFINITION;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.smallrye.graphql.federation.api;
package io.smallrye.graphql.api.federation;

import static io.smallrye.graphql.api.DirectiveLocation.FIELD_DEFINITION;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
Expand Down
46 changes: 0 additions & 46 deletions server/federation/README.adoc

This file was deleted.

27 changes: 0 additions & 27 deletions server/federation/api/pom.xml

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions server/federation/pom.xml

This file was deleted.

43 changes: 0 additions & 43 deletions server/federation/runtime/pom.xml

This file was deleted.

Loading

0 comments on commit 7aff796

Please sign in to comment.