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

SO
17h ago
+1045-31
  • 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.