feat(graphql): GraphQL client support + @Mapped enum binding + WebSocket subprotocols#5141
Open
shai-almog wants to merge 1 commit into
Open
feat(graphql): GraphQL client support + @Mapped enum binding + WebSocket subprotocols#5141shai-almog wants to merge 1 commit into
shai-almog wants to merge 1 commit into
Conversation
Collaborator
Author
|
Compared 11 screenshots: 11 matched. |
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Contributor
Cloudflare Preview
|
Contributor
✅ ByteCodeTranslator Quality ReportTest & Coverage
Benchmark Results
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
…ket subprotocols Adds a GraphQL client stack that mirrors the existing OpenAPI/gRPC "spec -> generated typed client" architecture, plus two enabling enhancements. GraphQL: - Runtime com.codename1.io.graphql: GraphQL invoker (HTTP POST queries/ mutations + decodeJson + encodeVariables), GraphQLResponse (data and errors co-exist), GraphQLError, GraphQLClients registry, and GraphQLSubscription over com.codename1.io.WebSocket (graphql-transport-ws). - Annotations com.codename1.annotations.graphql: @GraphQLClient, @Query/@Mutation/@subscription, @var (reuses @Header and @mapped). - GraphQLClientAnnotationProcessor emits <Name>Impl + cn1app.GraphQLClientBootstrap. - cn1:generate-graphql mojo with hand-written SDL + operation-document parsers; precise operations mode and schema-only bounded-depth mode. - Bootstrap wired into JavaSEPort + Executor like the REST/gRPC ones. @mapped enum binding: - AnnotatedClass.isEnum() + PropertyTypeKind.enumType(); MappingAnnotationProcessor upgrades REFERENCE->ENUM and detects List<Enum>, emitting name()/valueOf (unknown -> null) across JSON and XML. GraphQL response/input fields now use real enum types. WebSocket subprotocols: - WebSocket.subprotocols(String...) + getSelectedSubprotocol(), threaded through WebSocketImpl. Sec-WebSocket-Protocol implemented in JavaSE, Android, iOS (webSocketTaskWithURL:protocols: + didOpenWithProtocol:), and JavaScript. GraphQL subscriptions offer graphql-transport-ws. Tests: GenerateGraphQLMojoTest, GraphQLClientAnnotationProcessorTest, GraphQLResponseTest, plus enum round-trip and subprotocol negotiation tests for the mapper and WebSocket (core mock + JavaSE RFC 6455 echo). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
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.




















Summary
Adds a GraphQL client stack that slots into the same "spec → generated typed client" architecture as the existing OpenAPI (
@RestClient) and gRPC (@GrpcClient) support, plus two enabling enhancements that the GraphQL work needed and that stand on their own.GraphQL (
cn1:generate-graphql+@GraphQLClient)com.codename1.io.graphql:GraphQLinvoker (HTTPPOSTqueries/mutations, publicdecodeJson/encodeVariables),GraphQLResponse<T>(data and errors co-exist for partial results),GraphQLError,GraphQLClientsregistry, andGraphQLSubscriptionover the new corecom.codename1.io.WebSocketusing thegraphql-transport-wsprotocol.com.codename1.annotations.graphql:@GraphQLClient,@Query/@Mutation/@Subscription,@Var(reuses@Headerand@Mapped).GraphQLClientAnnotationProcessoremits<Name>Impl+cn1app.GraphQLClientBootstrap, registered in the annotation-processor SPI and wired intoJavaSEPort/Executorexactly like the REST/gRPC bootstraps.cn1:generate-graphqlwith hand-written SDL + operation-document parsers. Two modes: precise operations mode (per-selection@Mappedtypes, fragments inlined, operation document embedded verbatim) and a schema-only quick-start mode (bounded-depth auto-selection,cn1.graphql.maxDepth).@Mappedenum bindingPreviously an enum-typed field was classified as a nested reference, found no mapper, and silently didn't serialise. Now
AnnotatedClass.isEnum()+PropertyTypeKind.enumType()letMappingAnnotationProcessorupgradeREFERENCE → ENUM(and detectList<Enum>), emittingname()on write andvalueOfon read (unknown values decode tonull) across both JSON and XML. GraphQL response/input fields now use real enum types instead ofString.WebSocket subprotocols (
Sec-WebSocket-Protocol)The core
WebSocketfacade gainssubprotocols(String...)+getSelectedSubprotocol(), threaded throughWebSocketImpl. Implemented across every port: JavaSE + Android hand-rolled handshakes, iOS (webSocketTaskWithURL:protocols:+didOpenWithProtocol:, with the matchingIOSNativebridge rename), and JavaScript (new WebSocket(url, protocols)+w.protocol). GraphQL subscriptions offergraphql-transport-wsduring the handshake.Tests
GenerateGraphQLMojoTest(operations + schema-only modes, fragments, enum/input emission, records vs classes),GraphQLClientAnnotationProcessorTest(impl/bootstrap,GraphQL.execute/subscribe, error cases), and a new enum round-trip case inMappingAnnotationProcessorTest.GraphQLResponseTest(envelope decode, partial errors, variable encoding) and a subprotocol case inWebSocketTest.JavaSEWebSocketImplTest.All of the above pass locally (34 GraphQL/mapping/WebSocket tests) against the current master base.
Test plan
cd maven && mvn install -Plocal-dev-javase -DskipTests— core + plugin compile.mvn -pl codenameone-maven-plugin test -Dtest=GenerateGraphQLMojoTest,GraphQLClientAnnotationProcessorTest,MappingAnnotationProcessorTestmvn -DunitTests -pl core-unittests test -Dtest=GraphQLResponseTest,WebSocketTestmvn -pl javase test -Dtest=JavaSEWebSocketImplTest./scripts/build-android-port.sh -DskipTests— Android handshake change compiles../scripts/build-ios-port.sh -DskipTests— iOS nativeWebSocketImpl.m+IOSNative.mbridge compile under ParparVM.🤖 Generated with Claude Code