-
Notifications
You must be signed in to change notification settings - Fork 58
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 support for GraphQL over HTTP media type #558
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ struct MultipartResponseDeferParser: MultipartResponseSpecificationParser { | |
switch self { | ||
|
||
case let .unsupportedContentType(type): | ||
return "Unsupported content type: application/json is required but got \(type)." | ||
return "Unsupported content type: 'application/graphql-response+json' or 'application/json' are supported, received '\(type)'." | ||
case .cannotParseChunkData: | ||
return "The chunk data could not be parsed." | ||
case .cannotParsePayloadData: | ||
|
@@ -59,7 +59,7 @@ struct MultipartResponseDeferParser: MultipartResponseSpecificationParser { | |
for dataLine in chunk.components(separatedBy: Self.dataLineSeparator.description) { | ||
switch DataLine(dataLine.trimmingCharacters(in: .newlines)) { | ||
case let .contentHeader(type): | ||
guard type == "application/json" else { | ||
guard type == "application/graphql-response+json" || type == "application/json" else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should create a helper method for this. We're doing string comparisons against strings that are really constants. And we're doing the same comparison in two places. This is prone to future bugs. We should store the constants as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll put this PR back into draft and make that change when I get back. |
||
return .failure(ParsingError.unsupportedContentType(type: type)) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added tests to keep the existing behaviour of standard GraphQL response parsing including this odd one.