graphql / graphql/graphql-over-http

[Incremental Delivery Questions] How is the response protocol determined in different scenarios

Open
#167 10 comments 3 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
427
Forks
70
Avg merge
1m
Merged PRs (30d)
5

Description

I have a question regarding how the response protocol is determined for a request that could POTENTIALLY result in multiple payloads.

## Scenario: client sends header `accept: multipart/mixed` with non-"Incremental Delivery" operation

Given we have an operation that does not use defer/stream at all:

```graphql
query { foo }
```

Should the response then use the `application/(graphql+)json` response type or the `multipart/mixed` response type?

## Scenario: clients sends `accept: multipart/mixed, application/(graphql+)json` with non-"Incremental Delivery" operation

Given we have an operation that does not use defer/stream at all:

```graphql
query { foo }
```

Should the response then still use the `application/(graphql+)json` content-type or the `multipart/mixed` response type?
According to the current spec draft, the server should always please the order of the accept header listed content-types if possible. Would that still apply if the server is capable of serving both content-types (`accept: multipart/mixed` and `application/(graphql+)json`)

## Scenario: clients sends header `accept: application/(graphql+)json` with "Incremental Delivery" operation

```graphql
query {
foo
... on Query @defer {
bar
}
}
```

Quote from current Spec Draft:
> According to the HTTP 1.1 Accept specification, when a client does not include at least one supported content type in the Accept HTTP header, the server MAY choose to respond in one of several ways. The server MUST either:
>
> Disregard the Accept header and respond with the default content type of application/graphql+json, specifying this in the Content-Type header; OR
Respond with a 406 Not Acceptable status code

Should the server in this scenario still send back `multipart/mixed` or raise a 406 HTTP error?

Should the fact that the client sent an operation with a defer or stream directive be a hint to the server that the client MUST be able to parse it? A client not supporting it, would probably not have requested it in the first place?

Should the server be responsible for merging the results and sending them as a single result to the client?

Should the server do the execution with the defer and stream executor functionality being disabled?

## Scenario: clients sends the HTTP `GET` method

Is incremental delivery via `GET` allowed or intended?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.