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

Fix return error only #99

Merged
merged 4 commits into from
Mar 28, 2020

Conversation

longquan0104
Copy link
Contributor

Sorry I forget to add http.go when commit

@jbreeden-sfx
Copy link
Contributor

jbreeden-sfx commented Mar 26, 2020

FWIW: I tested the change to http.go on some of my queries and it looks mostly OK to me.

I'm loading a list of items, each with a child object that is federated (the first service resolves only the id, and another service returns the rest of the objects fields). Before this change, if any one federated child object failed on the remote service, I get all out failure and no data returned. After this change, I get a full list of data - albeit the failed item is missing the federated fields of the child - and one error explaining the one failed item.

One question though (and this may be a future enhancement): For the element that failed federation I still get the id field from the service that resolved the parent. That seems ok at first, but there are some field in the other service that are marked as required. Does it actually make sense to return the partial result with the id field in this case?

To make it more concrete, I basically have this (psuedo-code) schema in service 1:

type Query {
  getParents() [Parent]!
}

type Parent {
  id: ID!
  child: Child!
}

type Child implements Node {
  id: ID!
}

and this in service 2:

type Child implements Node {
  id: ID!
  name: String!
}

And now when I run this query:

{
  getParents {
    child {
      id
      name
    }
  }
}

I get Child objects with an id but no name, if there was an error in service 2, even though it's a required field.

This seems like it breaks the schema agreement to me. The service is now returning an object without some of the required fields. I think in those failure cases we may need to bubble up the null value to the parent, and so on, until we reach a nullable parent. That would keep to the GQL spec.

@AlecAivazis
Copy link
Member

Hello again! No worries about forgetting a few places, it's a pretty small change so it's easy to take in a few at a time. Once the merge conflict is resolved, I'll merge it in.

Also to answer your question, you are absolutely right. This does violate the schema agreement. Would you please copy and paste what you just wrote into a new issue? If it's something you want to try to address, I can offer some guidance on how I would approach it. Otherwise, someone will get to it eventually

@jbreeden-sfx
Copy link
Contributor

Sure thing! Created #100

I probably won't be able to address this right away. I'm about to start ramping up on a new project. But if I get a chance I'll ping you for guidance. Thanks!

@AlecAivazis
Copy link
Member

@longquan0104 since rebasing on master, it seems that the only net change is a single new empty line. Can you confirm? If so, I'll go ahead and close this

@longquan0104
Copy link
Contributor Author

Sorry that I edited wrong line. I just re-edit it

@AlecAivazis
Copy link
Member

Ah there we go! Alright, looks good to me

@AlecAivazis AlecAivazis merged commit cdfd064 into nautilus:master Mar 28, 2020
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

Successfully merging this pull request may close these issues.

3 participants