Skip to content

feat(gql): add graphql-to-jsonschema converter and selection set generator - #119

Open
Sooriya04 wants to merge 3 commits into
universal-tool-calling-protocol:mainfrom
Sooriya04:feat/graphql-schema-converter
Open

Sooriya04 wants to merge 3 commits into
universal-tool-calling-protocol:mainfrom
Sooriya04:feat/graphql-schema-converter

Conversation

@Sooriya04

@Sooriya04 Sooriya04 commented Oct 31, 2026 •

Copy link
Copy Markdown
  • Add schemaconverter to translate GraphQL types to UTCP JsonSchema
  • Support auto-generation of selection sets and polymorphic union fragments
  • Dynamically infer variable types and operation types from introspected schema
  • Add comprehensive offline unit tests and integration tests

Summary by cubic

Adds a GraphQL schema converter that generates UTCP JSON Schemas from introspected GraphQL types, and auto-generates selection sets so auto-built queries work for object-returning fields.

Previously, registered tools had empty object input/output schemas, and auto-generated queries for object-returning fields failed with missing selection set errors. Now field arguments and return types map to JSON Schemas preserving GraphQL nullability, unions render as member-specific oneOf with required __typename discriminators, and variable types and operation types are inferred from the schema. Selection sets are generated up to a configurable depth with union fragments and __typename fallbacks. You can override the generated selection per call with _fields or _selection arguments, or disable generation entirely with auto_generate_selection_set=False.

  • Adds schema_converter.py with GraphQL type converters, selection set generation, and union fragment support.
  • Adds auto_generate_selection_set and selection_depth (validated ≥ 1) options to GraphQLCallTemplate.
  • Filters selection-control args before sending them as GraphQL variables.
  • Fields resolve in the configured operation type root first, then fall back to others to avoid query/mutation name collisions.
  • session.execute compatibility is checked before execution, preventing duplicate mutation runs on TypeError.

Written for commit e8d022f. Summary will update on new commits.

View guided diff

…rator

- Add schemaconverter to translate
GraphQL types to UTCP JsonSchema
- Support auto-generation of selection sets and polymorphic union fragments
- Dynamically infer variable types and operation types from introspected schema
- Add comprehensive offline unit tests and integration tests

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

…ecution

- Execution correctness:
  * Check session.execute parameter compatibility before execution; remove
    broad try-except fallback to prevent mutations from executing twice on TypeError.
  * Resolve fields in configured operation_type root first before falling back,
    preventing query/mutation name collisions.

- Selection set generator:
  * Fall back to { __typename } when depth limits or objects lack scalar fields,
    preventing invalid bare-field syntax.
  * Recursively generate inline fragments for union fields nested inside object returns.
  * Enforce selection_depth >= 1 validation in GraphQLCallTemplate.

- Schema converter:
  * Preserve GraphQL nullability (type=[T, "null"] for nullable, type=T for NonNull).
  * Build union output schemas using member-specific oneOf schemas.
  * Support unconstrained types (object, array, string, number, boolean, null) for
    JSON scalar and reserve object for JSONObject.
  * Exclude defaulted NonNull arguments and input fields from required list.

- Tests:
  * Add regression tests for duplicate mutations, root precedence, nested unions,
    nullability, defaulted arguments, JSON scalars, and depth boundaries.
  * Assert recursion cutoff properties is None in input cycle tests and assert
    complete bounded selection string in selection cycle tests.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant