Repository navigation
Join GraphQL handlers on one field and write GraphQL type names - #31
Merged
Merged
Conversation
Handlers that call the same query or mutation with different returns or arguments now generate one field with lists, instead of stopping generate. graphqlType on a schema writes its GraphQL type name, and the scalar option accepts the built-in ID, String, Int, Float and Boolean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Broker 0.6.0 takes a list in
returnsandarguments, and anameon GraphQL scalars, objects and enums. This PR makesgeneratewrite both.Handlers on the same field are joined. Before this change, two handlers reading
query petwith differentreturnsorargumentsstoppedgeneratewith "declare the same returns in every handler". Now they generate one field. It lists every distinct schema, de-duplicated and sorted, with~for a handler that passes no arguments. A single schema is still written as a plain value.graphqlTypeis a new option on@BidirektSchema({ graphqlType: 'Pet' })and on@bidirekt schema graphqlType=Pet, above a class, an interface, an object type or a string enum. It writesname: Peton the schema, so the call breaks when the provider renames that type. Before, there was no way to declare the type name.Built-in scalars:
{ scalar: 'ID' }andscalar=IDwritetype: scalar, name: ID. The same works forString,Int,FloatandBoolean. That accepts the provider'sIDand breaks onString, while'string'accepts both. The SDK already wrote these. The broker accepts them since 0.6.0, and the README now says so.Files
src/model/protocols/graphql/contract.ts:Operation.argumentsandreturnsbecome lists (null= no arguments).src/model/protocols/graphql/blocks-to-merged.ts: groups the handlers of a field instead of refusing them.src/model/protocols/graphql/block-to-references.ts: walks every schema of the lists.src/writer/protocols/graphql/block-to-yaml.ts: writes a plain value or a sorted flow list.src/reader/schema-classes.ts,src/reader/tag-schemas.ts,src/model/contract.ts,src/writer/contract-to-yaml.ts,packages/typescript-sdk/src/index.ts: thegraphqlTypeoption, written asname.tests/fixtures/rejects-graphql-conflicting-handlersbecomes the success fixturegraphql-consumer-joins-handlers. There are new fixturesgraphql-type-namesandgraphql-type-names-tags, and the key lists in six error fixtures now includegraphqlType.tests/e2e/run.sh: two handlers readquery pet, and one readsnickname, which the provider lacks. can-i-deploy breaks only onPetNickname.nickname. The declaredPet,IDandIntpass.README.md: joining,graphqlTypeand the built-in scalar names.🤖 Generated with Claude Code