package
1.1.0
Repository: https://github.com/dunstack/graphql-go.git
Documentation: pkg.go.dev

# README

Apollo Federation Subgraph Compatibility

Overview

This application was created to demonstrate that the library is fully compatible with the Apollo Federation Subgraph spec.

Compatibility Results

Federation 1 SupportFederation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🔲
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

*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:
    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:
    {
        "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:
    {
    "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
    

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author