createSubscriptions(server) { _subscriptionsTransportWs.SubscriptionServer.create({ execute: _graphql.execute, subscribe: _graphql.subscribe, onOperation: async (_message, params, webSocket) => Object.assign({}, params, await this._getGraphQLOptions(webSocket.upgradeReq)) }, { server, path: this.config.subscriptionsPath || (0, _requiredParameter.default)('You must provide a config.subscriptionsPath to createSubscriptions!') }); }
return await execute( schema, document,
test('graphql.execute', function (t) { resetAgent(done(t)) var schema = graphql.buildSchema('type Query { hello: String }') var root = { hello () { return Promise.resolve('Hello world!') } } var query = '{ hello }' var source = new graphql.Source(query) var documentAST = graphql.parse(source) agent.startTransaction('foo') graphql.execute(schema, documentAST, root).then(function (response) { agent.endTransaction() t.deepLooseEqual(response, { data: { hello: 'Hello world!' } }) agent.flush() }) })
test('graphql.execute - transaction ended', function (t) { t.plan(5) resetAgent(1, function (data) { t.strictEqual(data.transactions.length, 1) t.strictEqual(data.spans.length, 0) var trans = data.transactions[0] t.strictEqual(trans.name, 'foo') t.strictEqual(trans.type, 'custom') }) var schema = graphql.buildSchema('type Query { hello: String }') var root = { hello () { return Promise.resolve('Hello world!') } } var query = '{ hello }' var source = new graphql.Source(query) var documentAST = graphql.parse(source) agent.startTransaction('foo').end() graphql.execute(schema, documentAST, root).then(function (response) { t.deepLooseEqual(response, { data: { hello: 'Hello world!' } }) }) })
test('graphql.execute sync', function (t) { resetAgent(done(t)) var schema = graphql.buildSchema('type Query { hello: String }') var root = { hello () { return 'Hello world!' } } var query = '{ hello }' var source = new graphql.Source(query) var documentAST = graphql.parse(source) agent.startTransaction('foo') var response = graphql.execute(schema, documentAST, root) agent.endTransaction() t.deepLooseEqual(response, { data: { hello: 'Hello world!' } }) agent.flush() })
var path = '/subscriptions'; var subServer = new _subscriptionsTransportWs.SubscriptionServer({ execute: _graphql.execute, subscribe: _graphql.subscribe, schema: schema,
test('graphql.execute args object', function (t) { resetAgent(done(t)) var schema = graphql.buildSchema('type Query { hello: String }') var root = { hello () { return Promise.resolve('Hello world!') } } var query = '{ hello }' var source = new graphql.Source(query) var documentAST = graphql.parse(source) var args = { schema: schema, document: documentAST, rootValue: root } agent.startTransaction('foo') graphql.execute(args).then(function (response) { agent.endTransaction() t.deepLooseEqual(response, { data: { hello: 'Hello world!' } }) agent.flush() }) })