@croquiscom/crary-graphql
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,4 +0,18 @@ | ||
export { addArgumentToInfo } from './addArgumentToInfo'; | ||
import { GraphQLInputType, GraphQLResolveInfo, GraphQLSchema } from 'graphql'; | ||
import { addArgumentToInfo } from './addArgumentToInfo'; | ||
export { addArgumentToInfo }; | ||
import { conformInfoToSchema } from './conformInfoToSchema'; | ||
export { conformInfoToSchema }; | ||
export { getFieldList, getFieldList1st } from './getFieldList'; | ||
export { getFieldString } from './getFieldString'; | ||
export { removeArgumentFromInfo } from './removeArgumentFromInfo'; | ||
import { removeArgumentFromInfo } from './removeArgumentFromInfo'; | ||
export { removeArgumentFromInfo }; | ||
export interface IGraphQLResolveInfoMethods { | ||
addArgument(name: string, value: any, type: GraphQLInputType): this; | ||
removeArgument(name: string): this; | ||
conformToSchema(schema: GraphQLSchema, fragments?: Array<{ | ||
field: string; | ||
fragment: string; | ||
}>): this; | ||
} | ||
export declare function wrapInfo<T extends GraphQLResolveInfo = GraphQLResolveInfo>(info: T): T & IGraphQLResolveInfoMethods; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var addArgumentToInfo_1 = require("./addArgumentToInfo"); | ||
const addArgumentToInfo_1 = require("./addArgumentToInfo"); | ||
exports.addArgumentToInfo = addArgumentToInfo_1.addArgumentToInfo; | ||
const conformInfoToSchema_1 = require("./conformInfoToSchema"); | ||
exports.conformInfoToSchema = conformInfoToSchema_1.conformInfoToSchema; | ||
var getFieldList_1 = require("./getFieldList"); | ||
@@ -10,3 +12,9 @@ exports.getFieldList = getFieldList_1.getFieldList; | ||
exports.getFieldString = getFieldString_1.getFieldString; | ||
var removeArgumentFromInfo_1 = require("./removeArgumentFromInfo"); | ||
const removeArgumentFromInfo_1 = require("./removeArgumentFromInfo"); | ||
exports.removeArgumentFromInfo = removeArgumentFromInfo_1.removeArgumentFromInfo; | ||
function wrapInfo(info) { | ||
return Object.assign({}, info, { addArgument(name, value, type) { return addArgumentToInfo_1.addArgumentToInfo(this, name, value, type); }, | ||
removeArgument(name) { return removeArgumentFromInfo_1.removeArgumentFromInfo(this, name); }, | ||
conformToSchema(schema, fragments) { return conformInfoToSchema_1.conformInfoToSchema(this, schema, fragments); } }); | ||
} | ||
exports.wrapInfo = wrapInfo; |
@@ -1,10 +0,7 @@ | ||
import { GraphQLField, GraphQLFieldResolver, GraphQLInputType, GraphQLResolveInfo } from 'graphql'; | ||
declare type GraphQLResolveInfoWithMethods = GraphQLResolveInfo & { | ||
addArgument(this: GraphQLResolveInfoWithMethods, name: string, value: any, type: GraphQLInputType): GraphQLResolveInfoWithMethods; | ||
removeArgument(this: GraphQLResolveInfoWithMethods, name: string): GraphQLResolveInfoWithMethods; | ||
}; | ||
import { GraphQLField, GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'; | ||
import { IGraphQLResolveInfoMethods } from '../info'; | ||
declare type ResolverHookFunction = (source: any, args: { | ||
[argName: string]: any; | ||
}, context: any, info: GraphQLResolveInfoWithMethods, resolve: GraphQLFieldResolver<any, any>) => Promise<any>; | ||
}, context: any, info: GraphQLResolveInfo & IGraphQLResolveInfoMethods, resolve: GraphQLFieldResolver<any, any>) => Promise<any>; | ||
export declare function hookResolver(field: GraphQLField<any, any>, fn: ResolverHookFunction): void; | ||
export {}; |
@@ -8,7 +8,5 @@ "use strict"; | ||
field.resolve = async (source, args, context, info) => { | ||
const infoWithMethods = Object.assign({}, info, { addArgument(name, value, type) { return info_1.addArgumentToInfo(this, name, value, type); }, | ||
removeArgument(name) { return info_1.removeArgumentFromInfo(this, name); } }); | ||
return fn(source, args, context, infoWithMethods, resolve); | ||
return fn(source, args, context, info_1.wrapInfo(info), resolve); | ||
}; | ||
} | ||
exports.hookResolver = hookResolver; |
{ | ||
"name": "@croquiscom/crary-graphql", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Croquis's library - graphql extension", | ||
@@ -26,3 +26,4 @@ "main": "./lib", | ||
"dependencies": { | ||
"graphql": "^14.4.1" | ||
"graphql": "^14.4.1", | ||
"graphql-tools": "^4.0.5" | ||
}, | ||
@@ -40,3 +41,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "c6f37653c9c42cd76098927aff33aa59ab112697" | ||
"gitHead": "3e89ec664d694a0e05952900299a3411821f60cb" | ||
} |
23859
32
527
2
+ Addedgraphql-tools@^4.0.5
+ Added@wry/equality@0.1.11(transitive)
+ Addedapollo-link@1.2.14(transitive)
+ Addedapollo-utilities@1.3.4(transitive)
+ Addeddeprecated-decorator@0.1.6(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedgraphql-tools@4.0.8(transitive)
+ Addedts-invariant@0.4.4(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedzen-observable@0.8.15(transitive)
+ Addedzen-observable-ts@0.8.21(transitive)