@croquiscom/crary-graphql
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -10,3 +10,3 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
import { GraphQLResolveInfo, GraphQLSchema } from 'graphql'; | ||
import { MergeInfo } from 'graphql-tools'; | ||
export declare function conformInfoToSchema<T extends GraphQLResolveInfo & { | ||
mergeInfo?: MergeInfo; | ||
} = GraphQLResolveInfo>(info: T, schema: GraphQLSchema, fragments?: { | ||
field: string; | ||
fragment: string; | ||
}[]): T; | ||
export declare function conformInfoToSchema<T extends GraphQLResolveInfo = GraphQLResolveInfo>(info: T, schema: GraphQLSchema, field_name?: string): T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.conformInfoToSchema = void 0; | ||
const delegate_1 = require("@graphql-tools/delegate"); | ||
const graphql_1 = require("graphql"); | ||
const graphql_tools_1 = require("graphql-tools"); | ||
function conformInfoToSchema(info, schema, fragments) { | ||
function conformInfoToSchema(info, schema, field_name) { | ||
var _a; | ||
let rootSelectionSet; | ||
if (field_name) { | ||
let selections = []; | ||
let args = []; | ||
info.fieldNodes.forEach((field) => { | ||
const fieldSelections = field.selectionSet | ||
? field.selectionSet.selections | ||
: []; | ||
selections = selections.concat(fieldSelections); | ||
args = args.concat(field.arguments || []); | ||
}); | ||
let selectionSet; | ||
if (selections.length > 0) { | ||
selectionSet = { | ||
kind: graphql_1.Kind.SELECTION_SET, | ||
selections, | ||
}; | ||
} | ||
const rootField = { | ||
kind: graphql_1.Kind.FIELD, | ||
arguments: args, | ||
selectionSet, | ||
name: { | ||
kind: graphql_1.Kind.NAME, | ||
value: field_name, | ||
}, | ||
}; | ||
rootSelectionSet = { | ||
kind: graphql_1.Kind.SELECTION_SET, | ||
selections: [rootField], | ||
}; | ||
} | ||
else { | ||
rootSelectionSet = { | ||
kind: graphql_1.Kind.SELECTION_SET, | ||
selections: info.fieldNodes, | ||
}; | ||
} | ||
const document = { | ||
kind: graphql_1.Kind.DOCUMENT, | ||
definitions: [ | ||
@@ -12,21 +52,10 @@ { | ||
operation: 'query', | ||
selectionSet: { | ||
kind: graphql_1.Kind.SELECTION_SET, | ||
selections: info.fieldNodes, | ||
}, | ||
selectionSet: rootSelectionSet, | ||
variableDefinitions: [], | ||
}, | ||
...Object.keys(info.fragments).map((fragmentName) => info.fragments[fragmentName]), | ||
], | ||
kind: graphql_1.Kind.DOCUMENT, | ||
}; | ||
if (!fragments) { | ||
if (info.mergeInfo) { | ||
fragments = info.mergeInfo.fragments; | ||
} | ||
else { | ||
fragments = []; | ||
} | ||
} | ||
const request = { document, variables: {} }; | ||
const transformed = new graphql_tools_1.FilterToSchema(schema).transformRequest(new graphql_tools_1.ReplaceFieldWithFragment(schema, fragments).transformRequest(request)); | ||
const transformed = new delegate_1.FilterToSchema(schema).transformRequest(new delegate_1.AddFragmentsByField(schema, (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a.stitchingInfo.fragmentsByField).transformRequest(request)); | ||
const definition = transformed.document.definitions[0]; | ||
@@ -33,0 +62,0 @@ return Object.assign(Object.assign({}, info), { fieldNodes: definition.selectionSet.selections }); |
@@ -19,7 +19,4 @@ import { GraphQLInputType, GraphQLResolveInfo, GraphQLSchema } from 'graphql'; | ||
removeArgument(name: string): this; | ||
conformToSchema(schema: GraphQLSchema, fragments?: { | ||
field: string; | ||
fragment: string; | ||
}[]): this; | ||
conformToSchema(schema: GraphQLSchema): this; | ||
} | ||
export declare function wrapInfo<T extends GraphQLResolveInfo = GraphQLResolveInfo>(info: T): T & IGraphQLResolveInfoMethods; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.wrapInfo = exports.removeFieldFromInfo = exports.removeArgumentFromInfo = exports.conformInfoToSchema = exports.addFieldToInfo = exports.addArgumentToInfo = void 0; | ||
exports.wrapInfo = exports.removeFieldFromInfo = exports.removeArgumentFromInfo = exports.getFieldString = exports.getFieldList1st = exports.getFieldList = exports.conformInfoToSchema = exports.addFieldToInfo = exports.addArgumentToInfo = void 0; | ||
const addArgumentToInfo_1 = require("./addArgumentToInfo"); | ||
@@ -24,4 +24,4 @@ Object.defineProperty(exports, "addArgumentToInfo", { enumerable: true, get: function () { return addArgumentToInfo_1.addArgumentToInfo; } }); | ||
removeArgument(name) { return removeArgumentFromInfo_1.removeArgumentFromInfo(this, name); }, | ||
conformToSchema(schema, fragments) { return conformInfoToSchema_1.conformInfoToSchema(this, schema, fragments); } }); | ||
conformToSchema(schema) { return conformInfoToSchema_1.conformInfoToSchema(this, schema); } }); | ||
} | ||
exports.wrapInfo = wrapInfo; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hookResolverAddArgument = exports.hookResolver = void 0; | ||
var hookResolver_1 = require("./hookResolver"); | ||
@@ -4,0 +5,0 @@ Object.defineProperty(exports, "hookResolver", { enumerable: true, get: function () { return hookResolver_1.hookResolver; } }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CrTimestamp = exports.CrJson = void 0; | ||
var json_1 = require("./json"); | ||
@@ -4,0 +5,0 @@ Object.defineProperty(exports, "CrJson", { enumerable: true, get: function () { return json_1.CrJson; } }); |
{ | ||
"name": "@croquiscom/crary-graphql", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Croquis's library - graphql extension", | ||
@@ -26,7 +26,9 @@ "main": "./lib", | ||
"dependencies": { | ||
"graphql": "^15.3.0", | ||
"graphql-tools": "^5.0.0" | ||
"@graphql-tools/delegate": "^6.2.4", | ||
"@graphql-tools/utils": "^6.2.4", | ||
"graphql": "^15.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.12", | ||
"@graphql-tools/stitch": "^6.2.4", | ||
"@types/chai": "^4.2.13", | ||
"@types/graphql": "^14.5.0", | ||
@@ -39,5 +41,4 @@ "@types/mocha": "^8.0.3", | ||
"tslint": "^6.1.3", | ||
"typescript": "^3.9.7" | ||
}, | ||
"gitHead": "9a4ac1c5e2f8defb9b09b15fdafbbdfa45f3d1c2" | ||
"typescript": "^4.0.3" | ||
} | ||
} |
37365
795
3
10
+ Added@graphql-tools/utils@^6.2.4
+ Added@ardatan/aggregate-error@0.0.6(transitive)
+ Added@graphql-tools/delegate@6.2.4(transitive)
+ Added@graphql-tools/schema@6.2.4(transitive)
+ Added@graphql-tools/utils@6.2.4(transitive)
+ Addedcamel-case@4.1.1(transitive)
+ Addeddataloader@2.0.0(transitive)
+ Addedis-promise@4.0.0(transitive)
+ Addedlower-case@2.0.2(transitive)
+ Addedno-case@3.0.4(transitive)
+ Addedpascal-case@3.1.2(transitive)
+ Addedtslib@2.0.3(transitive)
- Removedgraphql-tools@^5.0.0
- Removed@babel/runtime@7.26.9(transitive)
- Removed@wry/equality@0.1.11(transitive)
- Removedapollo-link@1.2.14(transitive)
- Removedapollo-link-http-common@0.2.16(transitive)
- Removedapollo-upload-client@13.0.0(transitive)
- Removedapollo-utilities@1.3.4(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddeprecated-decorator@0.1.6(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedextract-files@8.1.0(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedform-data@3.0.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.3.0(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedgraphql-tools@5.0.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removediterall@1.3.0(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedtr46@0.0.3(transitive)
- Removedts-invariant@0.4.4(transitive)
- Removeduuid@7.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedzen-observable@0.8.15(transitive)
- Removedzen-observable-ts@0.8.21(transitive)