MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / buildInputSchema

Function buildInputSchema

packages/plugins/graphql/src/sdk/extract.ts:136–162  ·  view source on GitHub ↗
(
  args: readonly IntrospectionInputValue[],
  types: ReadonlyMap<string, IntrospectionType>,
)

Source from the content-addressed store, hash-verified

134// ---------------------------------------------------------------------------
135
136const buildInputSchema = (
137 args: readonly IntrospectionInputValue[],
138 types: ReadonlyMap<string, IntrospectionType>,
139): Record<string, unknown> | undefined => {
140 if (args.length === 0) return undefined;
141
142 const properties: Record<string, unknown> = {};
143 const required: string[] = [];
144
145 for (const arg of args) {
146 const schema = typeRefToJsonSchema(arg.type, types);
147 if (arg.description) {
148 (schema as Record<string, unknown>).description = arg.description;
149 }
150 properties[arg.name] = schema;
151 if (isNonNull(arg.type)) {
152 required.push(arg.name);
153 }
154 }
155
156 const inputSchema: Record<string, unknown> = {
157 type: "object",
158 properties,
159 };
160 if (required.length > 0) inputSchema.required = required;
161 return inputSchema;
162};
163
164/** Format a type ref back to GraphQL type notation (e.g. "[String!]!") */
165const formatTypeRef = (ref: IntrospectionTypeRef): string =>

Callers 1

extractFieldsFunction · 0.70

Calls 3

typeRefToJsonSchemaFunction · 0.85
isNonNullFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected