graphql / graphql-spec

GraphQL is a query language and execution engine tied to any backend service.
https://spec.graphql.org
14.3k stars 1.12k forks source link

@defer + errors / nullability #185

Open rmosolgo opened 8 years ago

rmosolgo commented 8 years ago

Hey, thanks for the great talk about "experiements in GraphQL," so many good ideas there!

I'm exploring @defer and I have a couple clarifying questions about error handling.

Let's say you have a non-null field on an object which returns null (bad). The spec says the error should "propagate," making the parent object null:

However, if the type of that field is of a Non-Null type, since the field cannot be null the error is propagated to be dealt with by the parent field.

(Error Handling)

So,

  1. In that case, should we cancel all deferred fields whose parents were cancelled?
  2. If a non-null field was deferred, but returns null, should we patch the parent object to be null? Or simply not issue a patch for that illegally-null field?
dylanahsmith commented 8 years ago

Is @defer a relay specific directive? I see it is being talked about in https://github.com/facebook/graphql/issues/185 but it doesn't seemed to be defined in the spec at all. Is the talk on it available online?

rmosolgo commented 8 years ago

I heard about it here: https://youtu.be/ViXL0YQnioU?t=12m49s

stubailo commented 8 years ago

If you need a quick summary of the talk, I wrote one up here: https://medium.com/apollo-stack/new-features-in-graphql-batch-defer-stream-live-and-subscribe-7585d0c28b07#.voj1lkyus

rmosolgo commented 8 years ago

Maybe I asked the wrong question ... are @defer and @stream on a "standards track" at all?

rmosolgo commented 8 years ago

Ok, another question, might as well leave it here, is this supported:

... @defer {
  field1
  field2
}

If it is, do field1 & field2 come in the same patch? Or could it be the same as

field1 @defer 
field2 @defer