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

feature: Adds request Accept header #3167

Merged
merged 5 commits into from
Aug 1, 2023

Conversation

calvincestari
Copy link
Member

@calvincestari calvincestari commented Jul 31, 2023

Closes #3143
Related to #3146 (introduces the MultipartResponseDeferParser)

This PR ensures that when an operation is recognized as having deferred fragments the request automatically has the correct Accept HTTP header set to specify a multipart response and one that matches the currently configured defer spec parser.

@@ -70,6 +71,10 @@ public extension GraphQLOperation {
return nil
}

static var hasDeferredFragments: Bool {
false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will get set for each operation that has deferred fragments in it as part of the work for #3114.

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just have a question about deferred fragments in subscriptions.

)
}

if Operation.hasDeferredFragments {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a chance that we will have a subscription that also has deferred fragments? This would override that protocol spec in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think defer is supported in subscriptions. In that case we'd be indirectly relying on graphql-js to invalidate the operation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is graphql-js already handling that case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went looking for validation of my assumption and it was not as easy to find as I thought it was. I did find reference to not being allowed on a Subscription in the spec edits PR though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as it's definitely not allowed in the specification, I'm fine with merging this then. If there is a bug in the future, that is a bug in GraphQL-js not Apollo-iOS. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're fine. IMO defer on subscriptions is pointless.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, more confirmation in Apollo Client's httpLink.

@calvincestari calvincestari merged commit 66c1941 into feature/defer Aug 1, 2023
@calvincestari calvincestari deleted the defer/operation-request-header branch August 1, 2023 22:39
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.

Automatically add deferSpec to Accept header for deferred operations
3 participants