Skip to content

Commit

Permalink
feat: use latest version of graphql internally
Browse files Browse the repository at this point in the history
  • Loading branch information
dchambers committed May 10, 2022
1 parent dd00556 commit cce6216
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
graphql:
# Taking a sample from the most downloaded versions in the range "14 || 15 || 16"
versions: "^16.4.0 || 16.3.0 || 16.2.0 || ^15.8.0 || 15.7.2 || 15.6.1 || 15.6.0 || 15.5.3 || 15.5.1 || 15.5.0 || 15.4.0 || 15.3.0 || 14.7.0 || 14.6.0 || 14.5.8 || 14.0.0"
versions: "16.4.0 || 16.3.0 || 16.2.0 || 16.0.0 || ^15.8.0 || 15.7.2 || 15.6.1 || 15.6.0 || 15.5.3 || 15.5.1 || 15.5.0 || 15.4.0 || 15.3.0 || ^14.7.0 || 14.6.0 || 14.5.8 || 14.0.0"
commands: npm run test
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@opentelemetry/sdk-trace-base": "1.2.0",
"@types/mocha": "8.2.3",
"@types/node": "16.11.21",
"graphql": "^15.5.1",
"graphql": "^16.5.0",
"gts": "3.1.0",
"mocha": "7.2.0",
"nyc": "15.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ export class GraphQLInstrumentation extends InstrumentationBase {
schema: graphqlTypes.GraphQLSchema,
documentAST: graphqlTypes.DocumentNode,
rules?: ReadonlyArray<graphqlTypes.ValidationRule>,
typeInfo?: graphqlTypes.TypeInfo,
options?: { maxErrors?: number }
options?: { maxErrors?: number },
typeInfo?: graphqlTypes.TypeInfo
): ReadonlyArray<graphqlTypes.GraphQLError> {
return instrumentation._validate(
this,
Expand Down Expand Up @@ -373,8 +373,8 @@ export class GraphQLInstrumentation extends InstrumentationBase {
schema,
documentAST,
rules,
typeInfo,
options
options,
typeInfo
);
},
(err, errors) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export type validateType = (
schema: graphqlTypes.GraphQLSchema,
documentAST: graphqlTypes.DocumentNode,
rules?: ReadonlyArray<graphqlTypes.ValidationRule>,
typeInfo?: graphqlTypes.TypeInfo,
options?: { maxErrors?: number }
options?: { maxErrors?: number },
typeInfo?: graphqlTypes.TypeInfo
) => ReadonlyArray<graphqlTypes.GraphQLError>;

export interface GraphQLField {
Expand Down
10 changes: 8 additions & 2 deletions plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,13 @@ export function wrapFieldResolver<TSource = any, TContext = any, TArgs = any>(
>
>(
() => {
return fieldResolver.call(this, source, args, contextValue, info);
return fieldResolver.call(
this,
source,
args,
contextValue,
info
) as any;
},
err => {
if (shouldEndSpan) {
Expand Down Expand Up @@ -421,7 +427,7 @@ async function safeExecuteInTheMiddleAsync<T>(
try {
result = await execute();
} catch (e) {
error = e;
error = e as Error;
} finally {
onFinish(error, result);
if (error && !preventThrowingError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ const provider = new BasicTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
graphQLInstrumentation.setTracerProvider(provider);

const majorNodeVersion = Number(process.version.substring(1).split('.')[0]);
const itMaybe = majorNodeVersion >= 12 ? it : it.skip;

describe('graphql', () => {
function create(config: GraphQLInstrumentationConfig = {}) {
graphQLInstrumentation.setConfig(config);
Expand Down Expand Up @@ -976,7 +979,7 @@ describe('graphql', () => {
assert.deepStrictEqual(spans.length, 1);
});

it('should instrument parse with error', () => {
itMaybe('should instrument parse with error', () => {
const parseSpan = spans[0];
const event = parseSpan.events[0];

Expand Down Expand Up @@ -1043,7 +1046,7 @@ describe('graphql', () => {

describe('responseHook', () => {
let spans: ReadableSpan[];
let graphqlResult: graphqlTypes.ExecutionResult;
let graphqlResult: graphqlTypes.ExecutionResult<{ books: unknown[] }>;
const dataAttributeName = 'graphql_data';

afterEach(() => {
Expand Down

0 comments on commit cce6216

Please sign in to comment.