Skip to content

Commit

Permalink
Merge pull request #77 from lifeomic/updateGraphQl
Browse files Browse the repository at this point in the history
Update to more recent version of graphql
  • Loading branch information
David Tanner authored Dec 6, 2021
2 parents 758fb7f + 9d1b79f commit a1213ef
Show file tree
Hide file tree
Showing 11 changed files with 1,978 additions and 749 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Node.JS ${{ matrix.node-version }}
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (process.env.AWS_LAMBDA_FUNCTION_NAME) {
```

## AWS Segment Size Limitation
AWS has a 64K upload limit when submitting segements to AWS see [AWSXRay concepts segments](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-segments).
AWS has a 64K upload limit when submitting segments to AWS see [AWSXRay concepts segments](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-segments).

If you try and submit more than this limit you will see the following aws error message<br>**"<date> [ERROR] Segment too large to send: {<traceinformation...}"**

Expand Down
2 changes: 1 addition & 1 deletion codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ schema: ./test/**/*.graphql
generates:
test/__generated__/graphql.ts:
plugins:
- typescript
- "@graphql-codegen/typescript"
config:
useIndexSignature: true
namingConvention: keep
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lifeomic/graphql-resolvers-xray-tracing",
"version": "5.0.2",
"version": "6.0.0",
"description": "A GraphQL middleware to enable X-Ray tracing subsegments for GraphQL resolvers",
"homepage": "https://github.com/lifeomic/graphql-resolvers-xray-tracing#readme",
"bugs": {
Expand All @@ -10,6 +10,9 @@
"type": "git",
"url": "https://github.com/lifeomic/graphql-resolvers-xray-tracing.git"
},
"files": [
"src/**/*"
],
"scripts": {
"lint": "eslint . -f codeframe",
"pretypes": "yarn cleanTypes",
Expand All @@ -18,13 +21,13 @@
"test": "nyc ava",
"posttest": "yarn lint && tsc --noEmit",
"coverage": "nyc report --reporter=text-lcov > ./.nyc_output/lcov.info",
"prepublishOnly": "yarn tsc",
"prepublishOnly": "yarn tsc -p tsconfig.build.json",
"cleanTypes": "rm -rf test/__generated__"
},
"main": "src/traceResolvers.js",
"types": "src/traceResolvers.ts",
"types": "src/traceResolvers.d.ts",
"engines": {
"node": ">=10"
"node": ">=12"
},
"keywords": [
"graphql",
Expand All @@ -36,11 +39,10 @@
"author": "LifeOmic <[email protected]>",
"license": "MIT",
"devDependencies": {
"@graphql-codegen/cli": "1.2.1",
"@graphql-codegen/typescript": "1.2.1",
"@graphql-codegen/cli": "^2.3.0",
"@graphql-codegen/typescript": "^2.4.1",
"@graphql-toolkit/file-loading": "^0.10.7",
"@lifeomic/eslint-plugin-node": "^2.0.1",
"@types/graphql": "^14.0.7",
"@types/promise-retry": "^1.1.3",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^2.33.0",
Expand All @@ -49,8 +51,7 @@
"aws-xray-sdk-core": "^3.2.0",
"coveralls": "^3.1.0",
"eslint": "^7.16.0",
"graphql": "^14.0.2",
"graphql-tools": "^4.0.2",
"graphql": "^15.7.2",
"nock": "^13.0.5",
"nyc": "^15.1.0",
"promise-retry": "^2.0.1",
Expand All @@ -68,7 +69,8 @@
"branches": 100
},
"dependencies": {
"graphql-middleware": "^4.0.0",
"@graphql-tools/schema": "^8.3.1",
"graphql-middleware": "^6.1.12",
"is-promise": "^4.0.0"
},
"ava": {
Expand All @@ -88,6 +90,7 @@
"access": "public"
},
"peerDependencies": {
"aws-xray-sdk-core": "^2.5.0 || ^3.0.0"
"aws-xray-sdk-core": "^2.5.0 || ^3.0.0",
"graphql": "^15.7.2"
}
}
2 changes: 1 addition & 1 deletion test/helpers/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeExecutableSchema } from 'graphql-tools';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { v4 as uuid } from 'uuid';
import { loadFiles } from '@graphql-toolkit/file-loading';
import path from 'path';
Expand Down
6 changes: 3 additions & 3 deletions test/traceResolvers-contextMissing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { traceSchema } from './helpers/schema';
import nock from 'nock';
import anyTest, { TestInterface } from 'ava';
import AWSXRay from 'aws-xray-sdk-core';
import { ExecutionResult, ExecutionResultDataDefault } from 'graphql/execution/execute';
import { ExecutionResult } from 'graphql/execution/execute';
AWSXRay.setContextMissingStrategy('LOG_ERROR');
AWSXRay.setLogger({
debug: () => undefined,
Expand All @@ -21,7 +21,7 @@ const source = new Source('', '', {
});

interface TestContext {
graphql: <TData = ExecutionResultDataDefault>(query: GraphQlQuery) => Promise<ExecutionResult<TData>>;
graphql: <TData = Record<string, any>>(query: GraphQlQuery) => Promise<ExecutionResult<TData>>;
}

const test = anyTest as TestInterface<TestContext>;
Expand All @@ -31,7 +31,7 @@ test.beforeEach((t) => {
nock.enableNetConnect('127.0.0.1');
const schema = traceSchema();

t.context.graphql = (query) => graphql(schema, query);
t.context.graphql = <T = Record<string, any>>(query: GraphQlQuery) => graphql(schema, query) as Promise<ExecutionResult<T>>;
});

test.afterEach.always(() => {
Expand Down
9 changes: 4 additions & 5 deletions test/traceResolvers.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { graphql } from 'graphql';
import { graphql, ExecutionResult } from 'graphql';
import { traceSchema } from './helpers/schema';
import nock from 'nock';
import anyTest, { ExecutionContext, TestInterface } from 'ava';
import AWSXRay, { Segment, Subsegment } from 'aws-xray-sdk-core';
import retryPromise from 'promise-retry';
import { ExecutionResult, ExecutionResultDataDefault } from 'graphql/execution/execute';
import { Mutation } from './__generated__/graphql';

AWSXRay.capturePromise();
Expand All @@ -15,7 +14,7 @@ type Namespace = ReturnType<typeof AWSXRay.getNamespace>;
interface TestContext {
ns: Namespace;
segment: Segment;
graphql: <TData = ExecutionResultDataDefault>(query: GraphQlQuery) => Promise<ExecutionResult<TData>>;
graphql: <TData = Record<string, any>>(query: GraphQlQuery) => Promise<ExecutionResult<TData>>;
}

const test = anyTest as TestInterface<TestContext>;
Expand All @@ -31,10 +30,10 @@ test.beforeEach(function (test) {
const segment = new AWSXRay.Segment('parent');
test.context.segment = segment;

test.context.graphql = ns.bind(function (query: GraphQlQuery) {
test.context.graphql = ns.bind(function <T = Record<string, any>> (query: GraphQlQuery) {
AWSXRay.setSegment(segment);
try {
return graphql(schema, query);
return graphql(schema, query) as Promise<ExecutionResult<T>>;
} finally {
segment.close();
}
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false
},
"include": [
"src/**/*"
]
}
9 changes: 4 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
"strictFunctionTypes": true,
"moduleResolution": "node",
"target": "es2017",
"lib": ["es2015", "es2016", "es2017", "es2018", "es2019", "es2020", "esnext.asynciterable"],
"lib": ["es2020", "esnext.asynciterable"],
"pretty": true,
"inlineSourceMap": true,
"inlineSources": true,
"resolveJsonModule": true,
"rootDir": ".",
"skipLibCheck": true
"skipLibCheck": true,
"declaration": true,
"noEmit": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
Expand Down
Loading

0 comments on commit a1213ef

Please sign in to comment.