-
Notifications
You must be signed in to change notification settings - Fork 254
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
Only common values are being considered when merging enum or input types #1763
Comments
Thanks for submitting @AakashSorathiya . It looks like this is a documentation bug as we slightly changed how enum types are merged during preview. While we're working on it, the details of the change are in this PR: #1672 The very short version is that output types are merged by union and input types are merged by intersection (which is the safest choice we can make). |
Thanks for the update @clenfest. I have one question related to this only. I want to apply filter on the property which is present in subgraph 1 only and filters are defined using Example subgraph 1
subgraph 2
supergraph schema will have intersection of input types
So here I will be able to apply filter on Dependencies are same as mentioned above. |
There is no real way to split the definition of an input object type accross subgraph, at least not at the moment, no, because we wouldn't have a good way to handle it at runtime. But in your example, I'm not entirely sure to understand how you'd like it to work. That is, the {
movie(filter: { title_matches: "Lord of the ring" })
} For "Subgraph 1" to have a chance to handle such request, it needs to know that The same reasoning kind of apply to "Subgraph 2". More precisely, your example defines Or type Movie @key(fields: "id") {
id: ID!
title: String
}
input _MovieFilter {
id_matches: String
title_matches: String
}
type Query {
movie2(filter: _MovieFilter): [Movie]
} In that case, there is again 2 subcases: either Or, you mean # Subgraph 1
type Movie @key(fields: "id") {
id: ID!
name: String
}
input _MovieFilter1 {
id_matches: String
name_matches: String
}
type Query {
movie(filter: _MovieFilter1): [Movie]
} # Subgraph 2
type Movie @key(fields: "id") {
id: ID!
title: String
}
input _MovieFilter2 {
id_matches: String
title_matches: String
}
type Query {
movie2(filter: _MovieFilter2): [Movie]
} Which while maybe a bit more verbose, make it clear in the API which queries are valid and which aren't. Will all that said, maybe what you are ultimately trying to achieve is different, and you want to allow both "Subgraph 1" and "Subgraph 2" to resolve the {
movie(filter: { name_matches: "foo" })
} would be send to "Subgraph 1" but: {
movie(filter: { title_matches: "foo" })
} would be send to "Subgraph 2". If that's the case, the I'm afraid this isn't something federation currently can do. But I'll point out that it's not so simple for federation to do such a thing because, given the API exposed by your example, the query: {
movie(filter: { name_matches: "bar", title_matches: "foo" })
} is a valid query, but how would the gateway dispatch such query? That's what I meant at the beginning of my comment when I said "we wouldn't have a good way to handle it at runtime". Anyway, I hope all of this helps, but let us know if something is still unclear. |
Thanks for the reply @pcmanus
Yes I was trying to achieve this only. But as you mentioned this can not be handled at runtime with federation so will look for a work around to handle it on our end. |
I am using federation v2. I have defined one
enum
type that is shared in two subgraphs. Now according to docs the composition of supergraph sdl should merge this enum from both subgraphs and it should contain all the values provided in subgraphs. But supergraph schema is having only common values between the two.Input
subgraph schema 1
subgraph schema 2
supergraph schema generated
supergraph schema expected
And if there is no common value between the two then composition throws error like
Same is happening with
input
types also.I am using
InterospectAndCompose
API for composing supergraph sdl.Dependencies
The text was updated successfully, but these errors were encountered: