From ae105be83c11a95c69920e508425e2cd792edd6d Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Thu, 22 Jun 2023 17:52:08 +0300 Subject: [PATCH] Prettier and lint --- examples/azure-functions/index.ts | 2 +- packages/plugins/newrelic/package.json | 7 +-- packages/plugins/newrelic/src/index.ts | 14 +++--- .../plugins/newrelic/tests/newrelic.spec.ts | 47 ++++++++++++------- .../plugins/sentry/__tests__/sentry.spec.ts | 2 +- pnpm-lock.yaml | 3 ++ 6 files changed, 46 insertions(+), 29 deletions(-) diff --git a/examples/azure-functions/index.ts b/examples/azure-functions/index.ts index 9b78a165c1..4bff4f2718 100644 --- a/examples/azure-functions/index.ts +++ b/examples/azure-functions/index.ts @@ -1,6 +1,6 @@ import { execute, parse, subscribe, validate } from 'graphql'; import { getGraphQLParameters, processRequest, Response } from 'graphql-helix'; -import { AzureFunction, Context, HttpRequest } from '@azure/functions'; +import type { AzureFunction, Context, HttpRequest } from '@azure/functions'; import { envelop, useLogger, useSchema } from '@envelop/core'; import { makeExecutableSchema } from '@graphql-tools/schema'; diff --git a/packages/plugins/newrelic/package.json b/packages/plugins/newrelic/package.json index e79b24f4ae..78eefee539 100644 --- a/packages/plugins/newrelic/package.json +++ b/packages/plugins/newrelic/package.json @@ -56,12 +56,13 @@ "tslib": "^2.5.0" }, "devDependencies": { - "@types/newrelic": "9.14.0", "@envelop/core": "^4.0.0", + "@graphql-tools/schema": "^10.0.0", + "@newrelic/test-utilities": "6.5.5", + "@types/newrelic": "9.14.0", "graphql": "16.6.0", "newrelic": "9.8.1", - "typescript": "4.8.4", - "@newrelic/test-utilities": "6.5.5" + "typescript": "4.8.4" }, "publishConfig": { "directory": "dist", diff --git a/packages/plugins/newrelic/src/index.ts b/packages/plugins/newrelic/src/index.ts index f66a07ba72..205a3dd1af 100644 --- a/packages/plugins/newrelic/src/index.ts +++ b/packages/plugins/newrelic/src/index.ts @@ -83,12 +83,12 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => { const transaction = instrumentationApi.agent.tracer.getTransaction(); if (!transaction) { logger.trace('No transaction found. Not recording resolver.'); - return () => { }; + return () => {}; } const transactionNameState = transaction.nameState; if (!transactionNameState) { logger.trace('No transaction name state found. Not recording resolver.'); - return () => { }; + return () => {}; } const delimiter = transactionNameState.delimiter; @@ -100,7 +100,7 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => { 'No active segment found at resolver call. Not recording resolver (%s).', formattedPath, ); - return () => { }; + return () => {}; } const resolverSegment = instrumentationApi.createSegment( @@ -110,7 +110,7 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => { ); if (!resolverSegment) { logger.trace('Resolver segment was not created (%s).', formattedPath); - return () => { }; + return () => {}; } resolverSegment.start(); resolverSegment.addAttribute(AttributeName.RESOLVER_FIELD_PATH, formattedPath); @@ -169,9 +169,9 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => { transactionNameState.verb, delimiter, operationType + - delimiter + - operationName + - (rootFields ? delimiter + rootFields.join('&') : ''), + delimiter + + operationName + + (rootFields ? delimiter + rootFields.join('&') : ''), ); } diff --git a/packages/plugins/newrelic/tests/newrelic.spec.ts b/packages/plugins/newrelic/tests/newrelic.spec.ts index 19a335e911..a6e1b45312 100644 --- a/packages/plugins/newrelic/tests/newrelic.spec.ts +++ b/packages/plugins/newrelic/tests/newrelic.spec.ts @@ -1,7 +1,7 @@ -import { AttributeName, useNewRelic } from '../src'; import { createTestkit } from '@envelop/testing'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { TestAgent } from '@newrelic/test-utilities'; +import { AttributeName, useNewRelic } from '../src'; describe('New Relic', () => { const schema = makeExecutableSchema({ @@ -42,7 +42,7 @@ describe('New Relic', () => { shim: helper.getShim(), }), ], - schema + schema, ); // Do some testing logic... @@ -60,10 +60,14 @@ describe('New Relic', () => { AttributeName.EXECUTION_OPERATION_TYPE, ]); expect( - tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_OPERATION_NAME).value + tx.trace.root._spanContext.customAttributes.attributes.get( + AttributeName.EXECUTION_OPERATION_NAME, + ).value, ).toBe(`Greetings`); expect( - tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_OPERATION_TYPE).value + tx.trace.root._spanContext.customAttributes.attributes.get( + AttributeName.EXECUTION_OPERATION_TYPE, + ).value, ).toBe(`query`); // Many metrics are not created until the transaction ends, if you're @@ -73,7 +77,9 @@ describe('New Relic', () => { // This will check that the metrics given have been created. Extra metrics // are allowed. expect( - helper.agent.metrics.getMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`) + helper.agent.metrics.getMetric( + `Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`, + ), ).toBeTruthy(); }); }); @@ -88,13 +94,17 @@ describe('New Relic', () => { shim: helper.getShim(), }), ], - schema + schema, ); - await testKit.execute(`query Greetings($name: String!) { hello(name: $name) }`, { name: 'Laurin' }); + await testKit.execute(`query Greetings($name: String!) { hello(name: $name) }`, { + name: 'Laurin', + }); expect( - tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_VARIABLES).value + tx.trace.root._spanContext.customAttributes.attributes.get( + AttributeName.EXECUTION_VARIABLES, + ).value, ).toBe(`{"name":"Laurin"}`); // Many metrics are not created until the transaction ends, if you're @@ -112,7 +122,7 @@ describe('New Relic', () => { shim: helper.getShim(), }), ], - schema + schema, ); await testKit.execute( @@ -124,11 +134,13 @@ describe('New Relic', () => { { verb: 'Hi', name: 'Dotan', - } + }, ); expect( - tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_VARIABLES).value + tx.trace.root._spanContext.customAttributes.attributes.get( + AttributeName.EXECUTION_VARIABLES, + ).value, ).toBe(`{"verb":"Hi"}`); // Many metrics are not created until the transaction ends, if you're @@ -147,14 +159,15 @@ describe('New Relic', () => { shim: helper.getShim(), }), ], - schema + schema, ); // Do some testing logic... await testKit.execute(`query Greetings { hello }`); - expect(tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_RESULT).value).toBe( - `{"data":{"hello":"Hello world!"}}` - ); + expect( + tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_RESULT) + .value, + ).toBe(`{"data":{"hello":"Hello world!"}}`); // Many metrics are not created until the transaction ends, if you're // missing metrics in your instrumentation tests, this may help. @@ -171,7 +184,7 @@ describe('New Relic', () => { shim: helper.getShim(), }), ], - schema + schema, ); // Do some testing logic... @@ -193,7 +206,7 @@ describe('New Relic', () => { shim: helper.getShim(), }), ], - schema + schema, ); // Do some testing logic... diff --git a/packages/plugins/sentry/__tests__/sentry.spec.ts b/packages/plugins/sentry/__tests__/sentry.spec.ts index b426aba493..b02300aeca 100644 --- a/packages/plugins/sentry/__tests__/sentry.spec.ts +++ b/packages/plugins/sentry/__tests__/sentry.spec.ts @@ -44,7 +44,7 @@ describe('sentry', () => { `); // run sentry flush - await new Promise(res => setTimeout(res, 10)); + await new Promise(res => setTimeout(res, 100)); const reports = sentryTestkit.reports(); expect(reports).toHaveLength(1); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5d51ee0c6..80775e0bfa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1127,6 +1127,9 @@ importers: '@envelop/core': specifier: ^4.0.0 version: link:../../core/dist + '@graphql-tools/schema': + specifier: ^10.0.0 + version: 10.0.0(graphql@16.6.0) '@newrelic/test-utilities': specifier: 6.5.5 version: 6.5.5