graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

Resolvers not getting merged

Open nemonemi opened this issue 3 years ago • 10 comments

In the example below, only the type gets merged correctly, but not the resolvers. Only one service gets resolved, I believe in a random fashion.

The Authors service defines only the id and name on the Author type:

type Query {
  authors: [Author!]!
  author(id: ID!): Author!
}

type Author {
  id: ID!
  name: String!
}

The Books service is extending the Author type with its own model and data:

type Query {
  books: [Book!]!
  book(id: ID!): Book!
  author(id: ID!): Author!
}

type Book {
  id: ID!
  title: String!
}

type Author {
  id: ID!
  books: [Book!]!
}

To Reproduce

  1. go to the sandbox
  2. if the service doesn't start or shows 502, go to the Server Control Panel on the left, and restart the server
  3. gateway starts on the port 4000
  4. execute the prepopulated query Author
  5. observe the error:
  6. Either the name property or the books property will be missing.

Also, here's the Github repo: https://github.com/nemonemi/graphql_ensemble/tree/testing-federation-kind-of-approach

Expected behavior I'm expecting both the types and the resolvers to be merged, and when the Author query is executed that both the name and the books properties are resolved.

Additional context I'm not sure if this model workflow should already be supported, or if this is a feature request.

nemonemi avatar May 26 '21 16:05 nemonemi

@dotansimha, @ardatan how can I assist you guys in any way in progressing with this issue?

nemonemi avatar May 30 '21 07:05 nemonemi

Hi @nemonemi and thank you for the report

Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow.

It seems already got into stage 1 thanks to your reproduction! Thank you for that!

Now in order to advance to stage 2 we'll need a failing test, would be great if someone could help progress the issues through the stages.

Thank you and sorry that this comment is not a complete solution (yet).

Urigo avatar May 31 '21 23:05 Urigo

I would be willing to do it, but due to the lack of time on my part, I'd appreciate a point in the right direction. Which library is responsible, that the tests should be added?

nemonemi avatar Jun 01 '21 09:06 nemonemi

looks like you should check GraphQL Tools first

Urigo avatar Jun 01 '21 10:06 Urigo

https://github.com/Urigo/graphql-mesh/discussions/1833

yaacovCR avatar Jun 01 '21 11:06 yaacovCR

@ardatan I have tested the latest libraries' versions, but nothing has changed in terms of behavior. Still, the type gets merged correctly, but the resolvers not.

Either one resolver gets applied, or the other.

nemonemi avatar Jun 13 '21 11:06 nemonemi

@nemonemi In Type Merging, you need to do some small definitions. We're currently working on it on this PR/branch; https://github.com/Urigo/graphql-mesh/blob/refactor/packages/transforms/type-merging/yaml-config.graphql

I created an example with alpha versions; https://codesandbox.io/s/inspiring-platform-4j2ki?file=/.meshrc.yml I think that's what you're looking for.

ardatan avatar Jun 17 '21 17:06 ardatan

Hi Arda, thanks for the info, I'll check it out and test it, hopefully soon.

nemonemi avatar Jun 21 '21 12:06 nemonemi

Hello @ardatan, I have come to a point to deal with this again as we are on the way to requiring a gateway solution by increasing the number of our services.

Thank you for the example. I can confirm that in your codesandbox it works, however, I have tried to map it to my repo without success. The steps applied are just not clear enough to deduce what is important, and the documentation is not much better.

Could you please help me out reason about what actually needs to be applied here to make this work?

https://codesandbox.io/s/graphql-ensemble-nx-iz6vm

p.s. in the Codesandbox' Server control panel open the screen with port 5000 to access the gateway in question.

nemonemi avatar Dec 19 '21 17:12 nemonemi

I have to say, I am pretty disappointed in how these tickets get addressed, let alone resolved.

I have managed to get this to work, but have encountered another issue that is simply not possible to resolve using documentation or existing tickets.

Although I have had high hopes for applying graphql-mesh to several places in my company, this kind of inattentiveness caused me to become demoralized to use this library.

nemonemi avatar Apr 12 '22 10:04 nemonemi