mercurius-gateway icon indicating copy to clipboard operation
mercurius-gateway copied to clipboard

shared schemas with @external/@extends dont work

Open HashDot opened this issue 3 years ago • 5 comments

Hi, first of all thanks for this great project.

I am in the process of switching from Apollo Federation to Mercurius and am running into a few problems. Everything I describe here works with Apollo Federation and I would like to continue doing the same. Here's the problem:

I am using the same schemas in different services such as meta information, person, address, etc. These basic schemas are in a separate service. These schemas are then used in another service via @extends/@external and extended if necessary. Unfortunately this does not work and I always get the following feedback from the gateway:

"message": "Cannot return null for non-nullable field Meta.status."

Query:

{
  customer {
    meta {
      message
      status
    }
    data {
      _id
      name
    }
  }
}

If I do the query directly on the respective service it works. Therefore I think it is the gateway or the merging of the schemas. I have created an example repo. Can someone help me?

Example Repo: https://github.com/HashDot/federation-example

HashDot avatar Mar 30 '21 16:03 HashDot

Thanks for reporting! I currently do not have much time to diagnose this but I'm happy to review any PRs.

mcollina avatar Mar 30 '21 16:03 mcollina

Thanks for your quick reply. Then I will try another variant in the meantime and when I have time I will take a closer look. But maybe someone else has an idea what it is.

HashDot avatar Mar 30 '21 18:03 HashDot

Hi @HashDot I've looked into your federation-example repo but as far as I can tell the graphql schemas are loaded from the vault which isn't provided.

Have you looked at the gateway example which includes @extends cross service and works as expected? What's different from your setup/needs?

The test extends-directive also implements extends cross service.

Please detail if there's a scenario not being covered by the existing tests.

alex-parra avatar Apr 12 '21 10:04 alex-parra

Hi @alex-parra thanks for your response. I've tried to fill in the services without the vault and the result is the same. I try to build a better and less complex example of my problem for better debugging.

HashDot avatar Apr 20 '21 11:04 HashDot

@HashDot sounds good!

alex-parra avatar Apr 21 '21 14:04 alex-parra