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

Types are not correct for federated extended types #4291

Closed
lgandecki opened this issue Jun 25, 2020 · 1 comment
Closed

Types are not correct for federated extended types #4291

lgandecki opened this issue Jun 25, 2020 · 1 comment

Comments

@lgandecki
Copy link

Describe the bug
The field resolvers types generated for federated types have too many things available on the parent object.

To Reproduce
I've shown some examples here:

https://codesandbox.io/s/fancy-wave-74cxh?file=/ProductResolvers.ts

Basically, for this schema:

extend type Product @key(fields: "sku") {
    sku: ID! @external
    size: Int @external
    weight: Int @external
    shippingEstimate: Int @requires(fields: "size weight")
    simpleShippingEstimate: Int
}

shippingEstimate should have size, weight and sku
and simpleShippingEstimate should only have sku available to it.
Unfortunately, they both get everything. This way programmers can make mistakes that can't be caught with types, unit tests, and would force us to write higher level graphql tests - but the problem is that I don't really want to test the connection between type definition in the schema and it's implementation through queries. In this service I might not even have a query that returns a Product - I might only want to extend a Product that's defined and exposed somewhere else.

I've actually made a tool for that - https://github.com/xolvio/federation-testing-tool , (which would dynamically create a _getProduct query for testing environment, among other things) but I really would rather not use it :-) it's useful for things like workshops, libraries, or more low level code, but for just making resolvers and testing them, I'd prefer to stick with types and unit tests. The way your fantastic tooling allows me to do with pretty much everything else :)

Is this on the roadmap? Do you guys agree that this is a problem? I could try to work on this, maybe with little help.

Thanks!

@dotansimha
Copy link
Owner

Hi @lgandecki ! It seems like a duplicate of #4089

There is a WIP PR here: #4232

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