@envelop/core
Advanced tools
Comparing version 0.2.2-alpha-aed2e8b.0 to 0.2.2
@@ -8,39 +8,2 @@ 'use strict'; | ||
function getExecuteArgs(args) { | ||
return args.length === 1 | ||
? args[0] | ||
: { | ||
schema: args[0], | ||
document: args[1], | ||
rootValue: args[2], | ||
contextValue: args[3], | ||
variableValues: args[4], | ||
operationName: args[5], | ||
fieldResolver: args[6], | ||
typeResolver: args[7], | ||
}; | ||
} | ||
/** | ||
* Utility function for making a execute function that handles polymorphic arguments. | ||
*/ | ||
const makeExecute = (executeFn) => (...polyArgs) => executeFn(getExecuteArgs(polyArgs)); | ||
function getSubscribeArgs(args) { | ||
return args.length === 1 | ||
? args[0] | ||
: { | ||
schema: args[0], | ||
document: args[1], | ||
rootValue: args[2], | ||
contextValue: args[3], | ||
variableValues: args[4], | ||
operationName: args[5], | ||
fieldResolver: args[6], | ||
subscribeFieldResolver: args[7], | ||
}; | ||
} | ||
/** | ||
* Utility function for making a subscribe function that handles polymorphic arguments. | ||
*/ | ||
const makeSubscribe = (subscribeFn) => (...polyArgs) => subscribeFn(getSubscribeArgs(polyArgs)); | ||
const trackedSchemaSymbol = Symbol('TRACKED_SCHEMA'); | ||
@@ -200,3 +163,15 @@ const resolversHooksSymbol = Symbol('RESOLVERS_HOOKS'); | ||
: (ctx) => ctx; | ||
const customSubscribe = makeSubscribe(async (args) => { | ||
const customSubscribe = async (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => { | ||
const args = argsOrSchema instanceof graphql.GraphQLSchema | ||
? { | ||
schema: argsOrSchema, | ||
document: document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
fieldResolver, | ||
subscribeFieldResolver, | ||
} | ||
: argsOrSchema; | ||
const onResolversHandlers = []; | ||
@@ -250,5 +225,17 @@ let subscribeFn = graphql.subscribe; | ||
return result; | ||
}); | ||
const customExecute = (onExecuteCbs.length | ||
? makeExecute(async (args) => { | ||
}; | ||
const customExecute = onExecuteCbs.length | ||
? async (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => { | ||
const args = argsOrSchema instanceof graphql.GraphQLSchema | ||
? { | ||
schema: argsOrSchema, | ||
document: document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
fieldResolver, | ||
typeResolver, | ||
} | ||
: argsOrSchema; | ||
const onResolversHandlers = []; | ||
@@ -311,4 +298,4 @@ let executeFn = graphql.execute; | ||
return result; | ||
}) | ||
: graphql.execute); | ||
} | ||
: graphql.execute; | ||
function prepareSchema() { | ||
@@ -395,2 +382,12 @@ if (!schema || schema[trackedSchemaSymbol]) { | ||
const useEnvelop = (envelop) => { | ||
return { | ||
onPluginInit({ addPlugin }) { | ||
for (const plugin of envelop._plugins) { | ||
addPlugin(plugin); | ||
} | ||
}, | ||
}; | ||
}; | ||
const DEFAULT_OPTIONS = { | ||
@@ -611,6 +608,3 @@ logFn: console.log, | ||
exports.formatError = formatError; | ||
exports.getExecuteArgs = getExecuteArgs; | ||
exports.getSubscribeArgs = getSubscribeArgs; | ||
exports.makeExecute = makeExecute; | ||
exports.makeSubscribe = makeSubscribe; | ||
exports.useEnvelop = useEnvelop; | ||
exports.useErrorHandler = useErrorHandler; | ||
@@ -617,0 +611,0 @@ exports.useExtendContext = useExtendContext; |
export * from '@envelop/types'; | ||
export * from './create'; | ||
export * from './util'; | ||
export * from './plugins/use-envelop'; | ||
export * from './plugins/use-logger'; | ||
@@ -5,0 +5,0 @@ export * from './plugins/use-timing'; |
export * from '@envelop/types'; | ||
import { parse, specifiedRules, validate, execute, isIntrospectionType, isObjectType, defaultFieldResolver, subscribe, getOperationAST, GraphQLError } from 'graphql'; | ||
import { parse, specifiedRules, validate, execute, isIntrospectionType, isObjectType, defaultFieldResolver, GraphQLSchema, subscribe, getOperationAST, GraphQLError } from 'graphql'; | ||
function getExecuteArgs(args) { | ||
return args.length === 1 | ||
? args[0] | ||
: { | ||
schema: args[0], | ||
document: args[1], | ||
rootValue: args[2], | ||
contextValue: args[3], | ||
variableValues: args[4], | ||
operationName: args[5], | ||
fieldResolver: args[6], | ||
typeResolver: args[7], | ||
}; | ||
} | ||
/** | ||
* Utility function for making a execute function that handles polymorphic arguments. | ||
*/ | ||
const makeExecute = (executeFn) => (...polyArgs) => executeFn(getExecuteArgs(polyArgs)); | ||
function getSubscribeArgs(args) { | ||
return args.length === 1 | ||
? args[0] | ||
: { | ||
schema: args[0], | ||
document: args[1], | ||
rootValue: args[2], | ||
contextValue: args[3], | ||
variableValues: args[4], | ||
operationName: args[5], | ||
fieldResolver: args[6], | ||
subscribeFieldResolver: args[7], | ||
}; | ||
} | ||
/** | ||
* Utility function for making a subscribe function that handles polymorphic arguments. | ||
*/ | ||
const makeSubscribe = (subscribeFn) => (...polyArgs) => subscribeFn(getSubscribeArgs(polyArgs)); | ||
const trackedSchemaSymbol = Symbol('TRACKED_SCHEMA'); | ||
@@ -195,3 +158,15 @@ const resolversHooksSymbol = Symbol('RESOLVERS_HOOKS'); | ||
: (ctx) => ctx; | ||
const customSubscribe = makeSubscribe(async (args) => { | ||
const customSubscribe = async (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => { | ||
const args = argsOrSchema instanceof GraphQLSchema | ||
? { | ||
schema: argsOrSchema, | ||
document: document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
fieldResolver, | ||
subscribeFieldResolver, | ||
} | ||
: argsOrSchema; | ||
const onResolversHandlers = []; | ||
@@ -245,5 +220,17 @@ let subscribeFn = subscribe; | ||
return result; | ||
}); | ||
const customExecute = (onExecuteCbs.length | ||
? makeExecute(async (args) => { | ||
}; | ||
const customExecute = onExecuteCbs.length | ||
? async (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => { | ||
const args = argsOrSchema instanceof GraphQLSchema | ||
? { | ||
schema: argsOrSchema, | ||
document: document, | ||
rootValue, | ||
contextValue, | ||
variableValues, | ||
operationName, | ||
fieldResolver, | ||
typeResolver, | ||
} | ||
: argsOrSchema; | ||
const onResolversHandlers = []; | ||
@@ -306,4 +293,4 @@ let executeFn = execute; | ||
return result; | ||
}) | ||
: execute); | ||
} | ||
: execute; | ||
function prepareSchema() { | ||
@@ -390,2 +377,12 @@ if (!schema || schema[trackedSchemaSymbol]) { | ||
const useEnvelop = (envelop) => { | ||
return { | ||
onPluginInit({ addPlugin }) { | ||
for (const plugin of envelop._plugins) { | ||
addPlugin(plugin); | ||
} | ||
}, | ||
}; | ||
}; | ||
const DEFAULT_OPTIONS = { | ||
@@ -595,3 +592,3 @@ logFn: console.log, | ||
export { EnvelopError, envelop, formatError, getExecuteArgs, getSubscribeArgs, makeExecute, makeSubscribe, useErrorHandler, useExtendContext, useLogger, useMaskedErrors, usePayloadFormatter, useSchema, useTiming }; | ||
export { EnvelopError, envelop, formatError, useEnvelop, useErrorHandler, useExtendContext, useLogger, useMaskedErrors, usePayloadFormatter, useSchema, useTiming }; | ||
//# sourceMappingURL=index.esm.js.map |
{ | ||
"name": "@envelop/core", | ||
"version": "0.2.2-alpha-aed2e8b.0", | ||
"version": "0.2.2", | ||
"sideEffects": false, | ||
@@ -9,3 +9,3 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@envelop/types": "0.1.5-alpha-aed2e8b.0" | ||
"@envelop/types": "0.1.4" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138043
16
1238
+ Added@envelop/types@0.1.4(transitive)
- Removed@envelop/types@0.1.5-alpha-aed2e8b.0(transitive)
Updated@envelop/types@0.1.4