UNPKG

1.38 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var graphql_1 = require("graphql");
4function buildExistsInfo(rootFieldName, schema) {
5 var queryType = schema.getQueryType() || undefined;
6 var type = queryType.getFields()[rootFieldName].type;
7 // make sure that just list types are queried
8 if (!graphql_1.isNonNullType(type) || !graphql_1.isListType(type.ofType)) {
9 throw new Error("Invalid exist query: " + rootFieldName);
10 }
11 var fieldNode = {
12 kind: 'Field',
13 name: { kind: 'Name', value: rootFieldName },
14 selectionSet: {
15 kind: 'SelectionSet',
16 selections: [
17 {
18 kind: 'Field',
19 name: { kind: 'Name', value: 'id' },
20 },
21 ],
22 },
23 };
24 return {
25 fieldNodes: [fieldNode],
26 fragments: {},
27 schema: schema,
28 fieldName: rootFieldName,
29 returnType: type,
30 parentType: queryType,
31 path: undefined,
32 rootValue: null,
33 operation: {
34 kind: 'OperationDefinition',
35 operation: 'query',
36 selectionSet: { kind: 'SelectionSet', selections: [] },
37 variableDefinitions: [],
38 },
39 variableValues: {},
40 };
41}
42exports.buildExistsInfo = buildExistsInfo;
43//# sourceMappingURL=info.js.map
\No newline at end of file