Repository navigation
fix(graphql): ship kotlinx serializers for the GraphQL wire types - #55
Merged
Merged
Conversation
GraphQLServerRequest and GraphQLResponse are Jackson-only types: a kotlinx ContentNegotiation can neither read a request body nor write a response, so every GraphQL call died with 'Cannot transform this request's content' regardless of the headers. graphQLSerializersModule now carries both directions and consumers register it in their JSON converter. Also: argument resolution moved inside the guarded block of the request handler, so a malformed parameter is refused with its 400 instead of escaping as a 500.
The log read Content-Length from the response headers, which the engine computes while writing and often never exposes there: every request printed 'NaN'. ResponseSizeRecorder now measures the outgoing content at send time (hook ResponseBodyReadyForSend) and stores the size in a call attribute that the request log formats - whatever the engine and the negotiated format. Verified on real HTTP integration tests: End - AnimeController.findById (27.56 ms; 66 B).
…L serializers The private extensions of GraphQLServerRequestSerializer now sit at the top of the file and all carry their KDoc, and the list mappings use method references (GraphQLRequest::toElement, JsonElement::toValue, Any?::toElementValue) instead of lambdas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #47, found and verified with real HTTP integration tests.
fix(graphql): kotlinx serializers for the GraphQL wire types
Root cause:
GraphQLServerRequestandGraphQLResponse(graphql-kotlin-server 10.2.2) are annotated for Jackson / FastJson only - no kotlinx serializer exists. A kotlinx ContentNegotiation therefore can neither parse a GraphQL body nor write its response:Cannot transform this request's content to GraphQLServerRequestwhatever the Content-Type/Accept.graphQLSerializersModulecarries both directions (single request object, batch array;data/errors/extensionsresponse) - consumers register it withconfigureDefaultModules(graphQLSerializersModule);configureContentNegotiationaccepts extraSerializersModules merged into the JSON converter;MessageDtoinstead of escaping as a 500.fix(ktor): the real response size in the request logs
The log read
Content-Lengthfrom the response headers, which the engine computes while writing and often never exposes there: every request printedNaN.ResponseSizeRecordermeasures the outgoing content at send time (ResponseBodyReadyForSend) and stores it in a call attribute the request log formats - whatever the engine and the negotiated format.style
Top-level extensions at the top of the file, KDoc on all of them (private included), and method references over lambdas in the GraphQL serializers.
Verified end to end (core
api/src/integrationTest)Real embedded server, real HTTP requests:
POST /graphqlwith a query body -> 200 with data (died before);GET /animesin json, protobuf and cbor -> 200 in all three;NaN);GET /animes/not-a-uuid-> 400.Version bumped to 0.0.23-SNAPSHOT (core pinned on it).