error SATISFIABILITY_ERROR when check the schema

190 Views Asked by At

I tried to use Federation in my supergraph. I have 2 microservices, each one with the own schema: 1. first subgraph has:

type User @key(fields: id) @guard {
      id: ID!
      firstname: String!
   }

2. second subgraph has:

type GraphUnion {
   id: ID!
   user_id: Int
   text: String
   user: User! @hasOne 
}
type User @extends @key(fields: "id") {
    id: ID! @external
}

I make a Type(app/graphql/types) in the second microservice where I extend the User:

final class User
{
    public function __invoke($representation): array
    {
        return [
            '__typename' => 'User',
            'id' => 23
        ];
    }
}

When I use rover subgraph check ... I received the following

 SATISFIABILITY_ERROR: The following supergraph API query:
    {
      graphUnion {
        user {
          firstname
        }
      }
    }
    cannot be satisfied by the subgraphs because:
    - from subgraph "...":
      - cannot find field "User.firstname".
      - cannot move to subgraph "users", which has field "User.firstname", because type "User" has no @key defined in subgraph "users".

Could someone help me?

I tried to do all the steps from documentation from lighthouse ... also from Apollo, but didn't work

1

There are 1 best solutions below

0
Bogdan Lepinzan On

Try

php artisan -W --federation lighthouse:print-schema

That way the schema generated by the library also contains @key, @extend and @external directives.

I didn't find in the documentation for that part with --federation or I somehow missed that.