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 - 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.graphql - invalid query', function (t) { resetAgent(done(t, 'Unknown Query')) var schema = graphql.buildSchema('type Query { hello: String }') var root = { hello () { return 'Hello world!' } } var query = '{ hello' agent.startTransaction('foo') graphql.graphql(schema, query, root).then(function (response) { agent.endTransaction() t.deepEqual(Object.keys(response), ['errors']) t.strictEqual(response.errors.length, 1, 'should have one error') t.ok(response.errors[0].message.indexOf('Syntax Error') !== -1, 'should return a sytax error') agent.flush() }) })
test(`GET ${path}`, function (t) { resetAgent(done(t, 'hello', path)) var schema = buildSchema('type Query { hello: String }') var root = { hello () {
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(`POST ${path}`, function (t) { resetAgent(done(t, 'hello', path)) var schema = buildSchema('type Query { hello: String }') var root = { hello () {
test('graphql.graphql - 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 'Hello world!' } } var query = '{ hello }' agent.startTransaction('foo').end() graphql.graphql(schema, query, root).then(function (response) { t.deepLooseEqual(response, { data: { hello: 'Hello world!' } }) }) })
test(`POST ${path} - sort multiple queries`, function (t) { resetAgent(done(t, 'hello, life', path)) var schema = buildSchema('type Query { hello: String, life: Int }') var root = { hello () {
test('graphql.graphql', function (t) { resetAgent(done(t)) var schema = graphql.buildSchema('type Query { hello: String }') var root = { hello () { return 'Hello world!' } } var query = '{ hello }' agent.startTransaction('foo') graphql.graphql(schema, query, root).then(function (response) { 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() }) })
test(`POST ${path} - named query`, function (t) { resetAgent(done(t, 'HelloQuery hello', path)) var schema = buildSchema('type Query { hello: String }') var root = { hello () {