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() })
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() }) })