Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEDERATION] error SATISFIABILITY_ERROR when check the schema #2440

Closed
LepinzanB opened this issue Aug 28, 2023 · 2 comments
Closed

[FEDERATION] error SATISFIABILITY_ERROR when check the schema #2440

LepinzanB opened this issue Aug 28, 2023 · 2 comments

Comments

@LepinzanB
Copy link

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?

@spawnia
Copy link
Collaborator

spawnia commented Aug 29, 2023

Please share your solution, it is common courtesy to do so when you previously asked for help

@LepinzanB
Copy link
Author

LepinzanB commented Aug 29, 2023

After I used, php artisan -W --federation lighthouse:print-schema worked.
I didn't find in the documentation that part with --federation or I somehow missed that.

In that way the schema generate by library contains also @key, @extend and @external directives.

**print-schema**

php artisan lighthouse:print-schema
This can be quite useful, as the root .graphql files do not necessarily contains the whole schema. Schema imports, native PHP types and schema manipulation may influence the final schema.

Use the -W / --write option to output the schema to the default file storage (usually storage/app) as lighthouse-schema.graphql.

You can output your schema in JSON format by using the --json flag

This is in documentation, I think you can add also --federation

I found it in the code:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants