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

Function extractFields

packages/plugins/graphql/src/sdk/extract.ts:177–211  ·  view source on GitHub ↗
(
  _schema: IntrospectionSchema,
  kind: GraphqlOperationKind,
  typeName: string | null | undefined,
  types: ReadonlyMap<string, IntrospectionType>,
)

Source from the content-addressed store, hash-verified

175// ---------------------------------------------------------------------------
176
177const extractFields = (
178 _schema: IntrospectionSchema,
179 kind: GraphqlOperationKind,
180 typeName: string | null | undefined,
181 types: ReadonlyMap<string, IntrospectionType>,
182): ExtractedField[] => {
183 if (!typeName) return [];
184
185 const type = types.get(typeName);
186 if (!type?.fields) return [];
187
188 return type.fields
189 .filter((f) => !f.name.startsWith("__"))
190 .map((field) => {
191 const args = field.args.map((arg) =>
192 GraphqlArgument.make({
193 name: arg.name,
194 typeName: formatTypeRef(arg.type),
195 required: isNonNull(arg.type),
196 description: arg.description ? Option.some(arg.description) : Option.none(),
197 }),
198 );
199
200 const inputSchema = buildInputSchema(field.args, types);
201
202 return ExtractedField.make({
203 fieldName: field.name,
204 kind,
205 description: field.description ? Option.some(field.description) : Option.none(),
206 arguments: args,
207 inputSchema: inputSchema ? Option.some(inputSchema) : Option.none(),
208 returnTypeName: unwrapTypeName(field.type),
209 });
210 });
211};
212
213// ---------------------------------------------------------------------------
214// Public API

Callers 1

extractFunction · 0.85

Calls 5

isNonNullFunction · 0.85
formatTypeRefFunction · 0.70
buildInputSchemaFunction · 0.70
unwrapTypeNameFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected