Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions example/apollo_federation/subgraph/schema.graphql

This file was deleted.

166 changes: 0 additions & 166 deletions example/apollo_federation/subgraph/server.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Apollo Federation

**NOTE: This library doesn't support the full Apollo Federation subgraph spec!**

A basic example of integration with apollo federation as subgraph. Tested with Go v1.18, Node.js v16.14.2 and yarn 1.22.18.

To run this server

`go run ./example/apollo_federation/subgraph_one/server.go`
`go run ./example/apollo-federation/subgraph-one/server.go`

`go run ./example/apollo_federation/subgraph_two/server.go`
`go run ./example/apollo-federation/subgraph-two/server.go`

`cd example/apollo_federation/gateway`
`cd example/apollo-federation/gateway`

`yarn start`

Expand Down
113 changes: 113 additions & 0 deletions example/federation/compatibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Apollo Federation Subgraph Compatibility

## Overview
This application was created to demonstrate that the library is fully compatible with [the Apollo Federation Subgraph spec](https://www.apollographql.com/docs/federation/subgraph-spec/).

## Compatibility Results

<table>
<thead>
<tr><th>Federation 1 Support</th><th>Federation 2 Support</th></tr>
</thead>
<tbody>
<tr><td><table><tr><th><code>_service</code></th><td>🟢</td></tr><tr><th><code>@key (single)</code></th><td>🟢</td></tr><tr><th><code>@key (multi)</code></th><td>🟢</td></tr><tr><th><code>@key (composite)</code></th><td>🟢</td></tr><tr><th><code>repeatable @key</code></th><td>🟢</td></tr><tr><th><code>@requires</code></th><td>🟢</td></tr><tr><th><code>@provides</code></th><td>🟢</td></tr><tr><th><code>federated tracing</code></th><td>🔲</td></tr></table></td><td><table><tr><th><code>@link</code></th><td>🟢</td></tr><tr><th><code>@shareable</code></th><td>🟢</td></tr><tr><th><code>@tag</code></th><td>🟢</td></tr><tr><th><code>@override</code></th><td>🟢</td></tr><tr><th><code>@inaccessible</code></th><td>🟢</td></tr><tr><th><code>@composeDirective</code></th><td>🟢</td></tr><tr><th><code>@interfaceObject</code></th><td>🟢</td></tr></table></td></tr>
</tbody>
</table>

><sup>*</sup>This app intentionally does not demonstrate the use of Apollo Tracing since this is not part of the GraphQL spec. However, you can implement it yourself.

## Test it yourself

The application also has the graphiql interface available at `/graphiql` and you can play with the server. Particularly interesting queries are those using the `_entities` resolver and providing different key representations of type `_Any`. Below is a sample query you can play with. In order to run it:
1. Run `go run .`
2. Navigate to http://localhost:4001/graphiql
3. Copy the query below into the GraphiQL UI:
```graphql
query ($representations: [_Any!]!) {
_entities(representations: $representations) {
__typename
...on DeprecatedProduct { sku package reason }
...on Product { id sku createdBy { email name } }
...on ProductResearch { study { caseNumber description } }
...on User { email name }
}
}
```
4. Paste this into the variables section:
```json
{
"representations": [
{
"__typename": "DeprecatedProduct",
"sku": "apollo-federation-v1",
"package": "@apollo/federation-v1"
},
{
"__typename": "ProductResearch",
"study": {
"caseNumber": "1234"
}
},
{ "__typename": "User", "email": "[email protected]" },
{
"__typename": "Product",
"id": "apollo-federation"
},
{
"__typename": "Product",
"sku": "federation",
"package": "@apollo/federation"
},
{
"__typename": "Product",
"sku": "studio",
"variation": { "id": "platform" }
}
]
}
```
5. After executing the query you should see the following result:
```josn
{
"data": {
"_entities": [
{
"__typename": "DeprecatedProduct",
"package": "@apollo/federation-v1",
"reason": "Migrate to Federation V2"
},
{
"__typename": "ProductResearch",
"study": {
"caseNumber": "1234",
"description": "Federation Study"
}
},
{
"__typename": "User",
"email": "[email protected]",
"name": "Jane Smith"
},
{
"__typename": "Product",
"id": "apollo-federation",
"sku": "federation"
},
{
"__typename": "Product",
"id": "apollo-federation",
"sku": "federation"
},
{
"__typename": "Product",
"id": "apollo-studio",
"sku": "studio"
}
]
}
}
```
6. In case you want to run the compatiblity tests yourself:
```
npx @apollo/[email protected] pm2 --endpoint http://localhost:4001
```
Loading