( args: readonly IntrospectionInputValue[], types: ReadonlyMap<string, IntrospectionType>, )
| 134 | // --------------------------------------------------------------------------- |
| 135 | |
| 136 | const 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!]!") */ |
| 165 | const formatTypeRef = (ref: IntrospectionTypeRef): string => |
no test coverage detected