graphql-ws
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -20,3 +20,2 @@ "use strict"; | ||
const iterall_1 = require("iterall"); | ||
const promise_to_iterable_1 = require("./utils/promise-to-iterable"); | ||
const is_subscriptions_1 = require("./utils/is-subscriptions"); | ||
@@ -211,6 +210,6 @@ const common_1 = require("./common"); | ||
const document = typeof baseParams.query !== 'string' ? baseParams.query : graphql_1.parse(baseParams.query); | ||
let executionIterable; | ||
let executionPromise; | ||
const validationErrors = graphql_1.validate(this.schema, document, this.specifiedRules); | ||
if (validationErrors.length > 0) { | ||
executionIterable = Promise.resolve(promise_to_iterable_1.createIterableFromPromise(Promise.resolve({ errors: validationErrors }))); | ||
executionPromise = Promise.resolve({ errors: validationErrors }); | ||
} | ||
@@ -223,19 +222,7 @@ else { | ||
connectionContext.filesIn[opId] = common_1.extractIncomingFiles(opId, connectionContext.socket, params.variables); | ||
const promiseOrIterable = executor(this.schema, document, this.rootValue, params.context, params.variables, params.operationName); | ||
if (!iterall_1.isAsyncIterable(promiseOrIterable) && promiseOrIterable instanceof Promise) { | ||
executionIterable = promiseOrIterable; | ||
} | ||
else if (iterall_1.isAsyncIterable(promiseOrIterable)) { | ||
executionIterable = Promise.resolve(promiseOrIterable); | ||
} | ||
else { | ||
console.error('Invalid `execute` return type! Only Promise or AsyncIterable are valid values!'); | ||
SubscriptionServer.sendError(connectionContext, opId, { | ||
message: 'GraphQL execute engine is not available', | ||
}); | ||
} | ||
executionPromise = Promise.resolve(executor(this.schema, document, this.rootValue, params.context, params.variables, params.operationName)); | ||
} | ||
return executionIterable.then((ei) => ({ | ||
executionIterable: iterall_1.isAsyncIterable(ei) ? | ||
ei : iterall_1.createAsyncIterator([ei]), | ||
return executionPromise.then((executionResult) => ({ | ||
executionIterable: iterall_1.isAsyncIterable(executionResult) ? | ||
executionResult : iterall_1.createAsyncIterator([executionResult]), | ||
params, | ||
@@ -245,3 +232,3 @@ })); | ||
let lastVal; | ||
iterall_1.forAwaitEach(iterall_1.createAsyncIterator(executionIterable), (value) => { | ||
iterall_1.forAwaitEach(executionIterable, (value) => { | ||
let result = value; | ||
@@ -248,0 +235,0 @@ connectionContext.filesOut[opId] = common_1.extractOutgoingFiles(result.data); |
{ | ||
"name": "graphql-ws", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "WebSocket transport for GraphQL", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
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
503117
10547