Repository navigation
Conversation
c26b151 to
1690ade
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The Document overload bypasses configured parser limits, allowing operations rejected by the string overload to reach the server instead of returning local errors.
1 open issue
What changed in this PR
Completes the GraphQL client HTTP binding over a borrowed Restlet client, adding local validation and configurable response limits.
Changes:
- Adds optional schema validation, parser options, response-size limits, and request customization.
- Adds interoperability tests for JSON variables, error responses, validation, limits, and frozen configuration.
- Updates the changelog with the client capabilities.
| File | Description |
|---|---|
org.restlet.ext.graphql/src/test/java/org/restlet/ext/graphql/GraphqlTestSchemas.java |
Adds input-echo and header fields for client tests. |
org.restlet.ext.graphql/src/test/java/org/restlet/ext/graphql/GraphqlClientTestCase.java |
Tests client behavior against Restlet and an independent HTTP server. |
org.restlet.ext.graphql/src/main/java/org/restlet/ext/graphql/GraphqlClientAdapter.java |
Adds validation, configurable limits, and request customization. |
changes.md |
Documents the expanded GraphQL client capabilities. |
Review effort: Balanced
| ExecutionResult invalid = validate(document); | ||
| return invalid != null | ||
| ? invalid | ||
| : send(AstPrinter.printAst(document), operationName, variables); |
There was a problem hiding this comment.
Declining: the parser options bound the cost of parsing untrusted text, and a Document overload receives an AST the caller already built, so there is nothing left to protect locally (the string overload doesn't parse either without a schema). Reprinting and reparsing every Document just to apply token limits would add cost for no safety gain; the server still applies its own limits.
- setSchema(GraphQLSchema): documents are parsed and validated locally, and invalid ones are returned as an ExecutionResult with errors without a network call. The adapter never fetches a schema. - setParserOptions for local parsing; setMaxResponseBytes (10 MiB by default) checked on the declared size and while reading, never truncated; setRequestCustomizer for API key headers. - Variables are serialized as JSON values: text with braces, quotes, backslashes and newlines round trips unchanged. - Tested against GraphqlServerAdapter and against an independent server (the JDK HttpServer running graphql-java the legacy way, with chunked application/json responses and a 422 with a GraphQL body). Refs #1584 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
1690ade to
4eaa979
Compare
|




Closes #1584. Part of #1581.
Summary
Completes
GraphqlClientAdapter.POST,Accept: application/graphql-response+json, application/json;q=0.9; variables serialized as JSON values, never templated as textsetSchema, documents (StringorDocument) are parsed with the adapter'sParserOptionsand validated; invalid ones return anExecutionResultwith errors and no network call. The adapter never fetches a schemaExecutionResult(nodatawhen execution didn't start)maxResponseBytes(10 MiB, checked on the declared size and while reading, never truncated) and non-GraphQL responses throwGraphqlTransportExceptionwith the status and a 1 KiB body excerptClient, or the request customizerThe HTTP status of a request error is not exposed on the
ExecutionResult;isDataPresent()tells request errors from execution results. A follow-up can expose it if callers need it.Validation
./mvnw -B verify -P default,test -pl org.restlet.ext.graphql: 31 tests, 0 failures; 96.3% instruction coverage (gate 80%); Spotless, SpotBugs, Javadoc,-Werrorand dependency convergence pass.New
GraphqlClientTestCase(6 tests), againstGraphqlServerAdapterand against an independent server: the JDKHttpServerrunning graphql-java the legacy way (chunkedapplication/json,200for validation errors,422with a GraphQL body on another path):{{…}}, quotes,{key=value}, backslashes, newlines and non-ASCII characters round trips unchanged in nested input objects (the escaping failures seen when GraphQL is templated as opaque JSON).4xxGraphQL bodies are results.🤖 Generated with Claude Code