Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0] Import graphql-extensions and apollo-engine-reporting and avoid global apollo-server-env #1259

Merged
merged 123 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
23f6de8
Export polyfills and types separately
martijnwalraven Jun 21, 2018
7ecb2fc
More imports from apollo-server-env
martijnwalraven Jun 27, 2018
0c732c9
Initial commit
martijnwalraven Oct 2, 2017
119dc64
Add .npmignore to avoid ignoring lib when publishing
martijnwalraven Oct 11, 2017
02ad273
0.0.2
martijnwalraven Oct 11, 2017
744bdb1
Reorganize code and clean up GraphQLExtension interface
martijnwalraven Oct 19, 2017
4a9844b
0.0.3
martijnwalraven Oct 19, 2017
04b3511
Add support for timing callbacks and add GraphQLExtensionStack
martijnwalraven Oct 24, 2017
88fb925
0.0.4
martijnwalraven Oct 24, 2017
456c351
Downgrade target in tsconfig.json from es2015 to es5
martijnwalraven Oct 24, 2017
935b1b3
0.0.5
martijnwalraven Oct 24, 2017
85bbfc0
Bump `graphql` peerDependency. (#3)
wtgtybhertgeghgtwtg Jan 16, 2018
dbcc8a5
0.0.6
martijnwalraven Jan 16, 2018
fcba877
Update dependencies
martijnwalraven Jan 16, 2018
892ee31
0.0.7
martijnwalraven Jan 16, 2018
7155b77
whenResultIsFinished fix for array results (#4)
toshok Feb 16, 2018
61f64ff
0.0.8
martijnwalraven Feb 16, 2018
e4f31f0
[apollo-bot] Update the Issue/PR Templates with auto label (#6)
Mar 2, 2018
7d76e16
Bump `graphql` peerDependency. (#7)
wtgtybhertgeghgtwtg Mar 27, 2018
4c2c31d
Update `graphql` peer dependency range to allow 0.13.x. (#8)
abernix Mar 27, 2018
d9d965f
Update `devDependencies` to latest versions. (#9)
abernix Mar 27, 2018
087f6fb
Allow `undefined` return values to `GraphQLExtension`'s `format()`. (…
abernix Mar 28, 2018
175bd85
0.0.9
abernix Mar 28, 2018
6fca07f
Fix lifecycle method invocations on extensions
martijnwalraven Mar 30, 2018
2872778
0.0.10
martijnwalraven Mar 30, 2018
3bc7e3e
Add changelog
martijnwalraven Apr 4, 2018
d534e27
Upgrade to TypeScript 2.8
glasser May 15, 2018
83de80f
Add tslint and prettier
glasser May 15, 2018
d6f875c
Remove magic from GraphQLExtensionStack constructor
glasser May 15, 2018
7a83caf
New extension API: didStart handlers return didEnd handlers
glasser May 15, 2018
3e7a980
0.1.0-beta.0
glasser May 16, 2018
a550924
Changelog
glasser May 16, 2018
ac379e8
Add magic back into GraphQLExtensionStack constructor
glasser May 16, 2018
7b937d9
0.1.0-beta.1
glasser May 16, 2018
295747f
Export more types
glasser May 17, 2018
0fab594
0.1.0-beta.2
glasser May 17, 2018
5ae2628
Fix lifecycle handlers to pass proper "this"
glasser May 18, 2018
7a92821
0.1.0-beta.3
glasser May 18, 2018
a7c2def
Pass options directly to start handlers; eliminate factory again
glasser May 29, 2018
f54fc1c
0.1.0-beta.4
glasser May 29, 2018
ef90a80
error handling in didEnd
glasser May 29, 2018
e4d1465
0.1.0-beta.5
glasser May 29, 2018
8b457d0
pass multiple errors to EndHandler
glasser May 29, 2018
77a32f6
0.1.0-beta.6
glasser May 29, 2018
3a862a9
add willSendResponse
glasser May 30, 2018
7e943eb
0.1.0-beta.7
glasser May 30, 2018
534b7c3
prettier
glasser May 30, 2018
422ad5e
reverse
glasser May 30, 2018
f507e08
get more initial options into requestDidStart
glasser Jun 1, 2018
8bd73fe
0.1.0-beta.8
glasser Jun 1, 2018
b4d4050
setFieldResolver for custom fieldResolver
chentsulin May 30, 2018
27bf739
0.1.0-beta.9
glasser Jun 2, 2018
c57035b
Actually, we already get the fieldResolver!
glasser Jun 2, 2018
8ee7cef
0.1.0-beta.10
glasser Jun 2, 2018
a2a8880
work without extensionStack
glasser Jun 2, 2018
ee960f5
0.1.0-beta.11
glasser Jun 2, 2018
e779b22
0.1.0-beta.12
glasser Jun 2, 2018
4e828e7
Send errors to willResolveField callback
glasser Jun 6, 2018
2dde473
0.1.0-beta.13
glasser Jun 6, 2018
9f49d14
willSendResponse can return a result
evans Jun 18, 2018
8806f88
0.1.0-beta.14
evans Jun 19, 2018
0dc2ef8
Revert 1063be8..56912fc
evans Jun 19, 2018
7c69bcd
add PQ options to requestDidStart
glasser Jun 23, 2018
7ace043
0.1.0-beta.14
glasser Jun 23, 2018
0ddeb52
0.1.0-beta.15
glasser Jun 23, 2018
b28a3ec
Initialize an empty TypeScript/Jest package
glasser May 17, 2018
604b90a
Basic trace node structure building
glasser May 18, 2018
972a717
basic timing
glasser May 18, 2018
e446862
Checkpoint towards signature implementation
glasser May 19, 2018
6434383
Basic signature implementation
glasser May 30, 2018
ec91f67
progress towards actual reporting
glasser May 31, 2018
5d0c30b
basic checkpoint for reporting
glasser May 31, 2018
d78d579
0.0.0-beta.1
glasser May 31, 2018
b0e640f
pull in @types/long, since it is in the external api
glasser May 31, 2018
c1b1d2d
0.0.0-beta.2
glasser May 31, 2018
cc667b0
get rid of Long
glasser May 31, 2018
f77ac9f
0.0.0-beta.3
glasser May 31, 2018
c5da16f
debug log request what happened
glasser May 31, 2018
2205261
0.0.0-beta.4
glasser May 31, 2018
b14c1d1
0.0.0-beta.5
glasser May 31, 2018
70e46a9
correct url
glasser May 31, 2018
3ab3b1d
0.0.0-beta.6
glasser May 31, 2018
2497771
request headers
glasser May 31, 2018
927557e
0.0.0-beta.7
glasser May 31, 2018
59bcbc7
leave out a few headers
glasser May 31, 2018
b3cf401
0.0.0-beta.8
glasser May 31, 2018
e622f8d
prettier
glasser May 31, 2018
fa885ba
move stuff into multiple files, and stop exporting the extension
glasser Jun 1, 2018
d990fc9
lots of doc comments
glasser Jun 1, 2018
9f4eeef
address agent.ts XXX comments
glasser Jun 5, 2018
f40addd
implement privateVariables
glasser Jun 6, 2018
9d88739
privateHeaders and error tracking
glasser Jun 6, 2018
6cceb00
gzip, signals
glasser Jun 7, 2018
7349af5
fix test
glasser Jun 7, 2018
b58b57c
0.0.0-beta.9
glasser Jun 7, 2018
c7de189
Error handling for reports
glasser Jun 11, 2018
0dad72e
0.0.0-beta.10
glasser Jun 11, 2018
8e271ca
no need to include boring stacktrace
glasser Jun 11, 2018
454f9da
0.0.0-beta.11
glasser Jun 11, 2018
9e741fc
tweak error reporting
glasser Jun 12, 2018
463cf7d
0.0.0-beta.12
glasser Jun 12, 2018
1ca448d
package-lock update (npm@6?)
glasser Jun 21, 2018
9085bfc
Reduce target report size to 512KB from 4MB.
glasser Jun 21, 2018
88123fe
0.0.0-beta.13
glasser Jun 21, 2018
ab2afe1
Encode Traces as they come in
glasser Jun 21, 2018
daf711e
0.0.0-beta.14
glasser Jun 21, 2018
0bb60ae
support PQ fields
glasser Jun 23, 2018
6479be9
npm audit fix
glasser Jun 23, 2018
7de6016
0.0.0-beta.15
glasser Jun 23, 2018
09f84da
ignore coverage
glasser Jun 23, 2018
2f9fc5c
Make the default signature more aggressive
glasser Jun 25, 2018
f17eec2
0.0.0-beta.16
glasser Jun 25, 2018
5365c75
Remove obsolete files from graphql-extensions and apollo-engine-repor…
martijnwalraven Jun 27, 2018
7dd63d2
Fix dependencies and configs
martijnwalraven Jun 27, 2018
7500f5a
Fix apollo-server-cloudflare to import from apollo-server-env
martijnwalraven Jun 27, 2018
9cfc473
Fix compilation and test configs
martijnwalraven Jun 27, 2018
bd0f224
Get all tests passing again
martijnwalraven Jun 27, 2018
391d08c
Switch to Lerna independent versioning
martijnwalraven Jun 27, 2018
030fc05
Polyfill promisify for Node < 8 and load polyfills in tests
martijnwalraven Jun 27, 2018
ca9b2ec
ES2016 exponentiation operator is only supported in Node > 6
martijnwalraven Jun 27, 2018
b654b5b
add dependency cache for circle
evans Jun 27, 2018
9fa227c
Merge branch 'version-2' into server-2.0/avoid-global-env
evans Jun 27, 2018
db727c6
add missing env dependencies in REST datasource
evans Jun 27, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ common_test_steps: &common_test_steps
steps:
- *run_install_desired_npm
- checkout
- run: cat ./packages/*/package.json > package-checksum
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}-{{ checksum "package-checksum" }}
- run: npm --version
- run: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}-{{ checksum "package-checksum" }}
paths:
- ./node_modules
- run: npm run travis

# Important! When adding a new job to `jobs`, make sure to define when it
Expand Down Expand Up @@ -62,8 +69,14 @@ jobs:
steps:
# (speed) Intentionally omitted, unnecessary, run_install_desired_npm.
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "./docs/package.json" }}
# (speed) Ignore scripts to skip the Lerna build stuff for linting.
- run: npm install-test --prefix ./docs
- save_cache:
key: dependency-cache-{{ checksum "./docs/package.json" }}
paths:
- ./docs/node_modules

ignore_doc_branches: &ignore_doc_branches
filters:
Expand Down
43 changes: 22 additions & 21 deletions __mocks__/fetch.ts → __mocks__/apollo-server-env.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
declare global {
namespace NodeJS {
interface Global {
fetch: typeof fetch;
}
}
}
import {
fetch,
Request,
Response,
BodyInit,
Headers,
URL,
URLSearchParams,
} from 'apollo-server-env';

type Headers = { [name: string]: string };

Expand All @@ -13,39 +15,38 @@ interface FetchMock extends jest.Mock<typeof fetch> {
mockJSONResponseOnce(data?: object, headers?: Headers);
}

const fetchMock = jest.fn<typeof fetch>() as FetchMock;
const mockFetch = jest.fn<typeof fetch>() as FetchMock;

fetchMock.mockResponseOnce = (
mockFetch.mockResponseOnce = (
data?: BodyInit,
headers?: Headers,
status: number = 200,
) => {
return fetchMock.mockImplementationOnce(async () => {
return mockFetch.mockImplementationOnce(async () => {
return new Response(data, {
status,
headers,
});
});
};

fetchMock.mockJSONResponseOnce = (
mockFetch.mockJSONResponseOnce = (
data = {},
headers?: Headers,
status?: number,
) => {
return fetchMock.mockResponseOnce(
return mockFetch.mockResponseOnce(
JSON.stringify(data),
Object.assign({ 'Content-Type': 'application/json' }, headers),
status,
);
};

export default fetchMock;

export function mockFetch() {
global.fetch = fetchMock;
}

export function unmockFetch() {
global.fetch = fetch;
}
export = {
fetch: mockFetch,
Request,
Response,
Headers,
URL,
URLSearchParams,
};
6 changes: 2 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "2.0.0",
"version": "2.0.0-rc.5",
"version": "independent",
"changelog": {
"repo": "apollographql/apollo-server",
"labels": {
Expand All @@ -13,7 +13,5 @@
}
},
"hoist": true,
"packages": [
"packages/*"
]
"packages": ["packages/*"]
}
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@
"node": ">=6"
},
"devDependencies": {
"@types/chai": "4.1.3",
"@types/chai": "^4.1.4",
"@types/graphql": "^0.13.1",
"@types/mocha": "5.2.1",
"@types/node": "^10.3.2",
"@types/mocha": "^5.2.3",
"@types/node": "^10.3.6",
"@types/sinon": "5.0.1",
"chai": "4.1.2",
"graphql": "0.13.2",
"husky": "0.14.3",
"istanbul": "1.1.0-alpha.1",
"lerna": "2.11.0",
"lint-staged": "7.2.0",
"mocha": "5.2.0",
"prettier": "1.13.5",
"prettier-check": "2.0.0",
"remap-istanbul": "0.11.1",
"sinon": "6.0.0",
"supertest": "3.1.0",
"typescript": "2.9.1"
"graphql": "^0.13.2",
"husky": "^0.14.3",
"istanbul": "^1.1.0-alpha.1",
"lerna": "^2.11.0",
"lint-staged": "^7.2.0",
"mocha": "^5.2.0",
"prettier": "^1.13.6",
"prettier-check": "^2.0.0",
"remap-istanbul": "^0.11.1",
"sinon": "^6.0.1",
"supertest": "^3.1.0",
"typescript": "^2.9.2"
}
}
14 changes: 10 additions & 4 deletions packages/apollo-datasource-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://github.com/apollographql/apollo-server/issues"
},
"scripts": {
"clean": "rm -rf lib",
"clean": "rm -rf dist",
"compile": "tsc",
"prepublish": "npm run clean && npm run compile",
"test": "jest --verbose"
Expand All @@ -30,13 +30,16 @@
"lru-cache": "^4.1.3"
},
"devDependencies": {
"@types/jest": "^23.0.0",
"@types/jest": "^23.1.2",
"@types/lru-cache": "^4.1.1",
"jest": "^23.1.0",
"jest": "^23.2.0",
"ts-jest": "^22.4.6"
},
"jest": {
"testEnvironment": "node",
"setupFiles": [
"<rootDir>/node_modules/apollo-server-env/dist/index.js"
],
"transform": {
"^.+\\.(ts|js)$": "ts-jest"
},
Expand All @@ -45,7 +48,10 @@
"js",
"json"
],
"testRegex": "/__tests__/.*$",
"testRegex": "apollo-datasource-rest/src/__tests__/.*$",
"roots": [
"../../"
],
"globals": {
"ts-jest": {
"skipBabel": true
Expand Down
9 changes: 9 additions & 0 deletions packages/apollo-datasource-rest/src/HTTPCache.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import {
fetch,
Request,
RequestInfo,
RequestInit,
Response,
Headers,
} from 'apollo-server-env';

import CachePolicy = require('http-cache-semantics');

import { KeyValueCache, InMemoryLRUCache } from 'apollo-server-caching';
Expand Down
11 changes: 11 additions & 0 deletions packages/apollo-datasource-rest/src/RESTDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import {
BodyInit,
Headers,
Request,
RequestInit,
Response,
URL,
URLSearchParams,
URLSearchParamsInit,
} from 'apollo-server-env';

import { HTTPCache } from './HTTPCache';
import {
ApolloError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'apollo-server-env';
import { fetch } from 'apollo-server-env';
import { HTTPCache } from '../HTTPCache';

import fetch, { mockFetch, unmockFetch } from '../../../../__mocks__/fetch';
import {
mockDate,
unmockDate,
Expand All @@ -13,7 +12,6 @@ describe('HTTPCache', () => {
let httpCache: HTTPCache;

beforeAll(() => {
mockFetch();
mockDate();
});

Expand All @@ -25,7 +23,6 @@ describe('HTTPCache', () => {
});

afterAll(() => {
unmockFetch();
unmockDate();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import 'apollo-server-env';
import { fetch } from 'apollo-server-env';

import {
ApolloError,
AuthenticationError,
ForbiddenError,
} from 'apollo-server-errors';
import { RESTDataSource } from '../RESTDataSource';

import fetch, { mockFetch, unmockFetch } from '../../../../__mocks__/fetch';
import { HTTPCache } from '../HTTPCache';

describe('RESTDataSource', () => {
const store = new Map<string, string>();
let httpCache: HTTPCache;

beforeAll(() => {
mockFetch();

httpCache = new HTTPCache({
async get(key: string) {
return store.get(key);
Expand All @@ -31,10 +29,6 @@ describe('RESTDataSource', () => {
store.clear();
});

afterAll(() => {
unmockFetch();
});

it('returns data as parsed JSON when Content-Type is application/json', async () => {
const dataSource = new class extends RESTDataSource {
baseURL = 'https://api.example.com';
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-engine-reporting/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!src/**/*
!dist/**/*
dist/**/*.test.*
!package.json
!README.md
4 changes: 4 additions & 0 deletions packages/apollo-engine-reporting/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### vNext

* Initial release.

6 changes: 6 additions & 0 deletions packages/apollo-engine-reporting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# apollo-engine-reporting

[![npm version](https://badge.fury.io/js/apollo-engine-reporting.svg)](https://badge.fury.io/js/apollo-engine-reporting)
[![Build Status](https://circleci.com/gh/apollographql/apollo-engine-reporting.svg?style=svg)](https://circleci.com/gh/apollographql/apollo-engine-reporting)

This package is a pure JS implementation of the Apollo Engine reporting feature. It is a work in progress and is not recommended for production use.
64 changes: 64 additions & 0 deletions packages/apollo-engine-reporting/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "apollo-engine-reporting",
"version": "0.0.0-beta.16",
"description": "Send reports about your GraphQL services to Apollo Engine",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"clean": "rm -rf dist",
"compile": "tsc",
"watch": "tsc -w",
"prepublish": "npm run clean && npm run compile",
"test": "jest --verbose",
"circle": "jest --verbose --coverage",
"lint": "prettier -l 'src/**/*.{ts,js}' && tslint -p tsconfig.json 'src/**/*.ts'",
"lint-fix": "prettier --write 'src/**/*.{ts,js}' && tslint --fix -p tsconfig.json 'src/**/*.ts'"
},
"license": "MIT",
"repository": "https://github.com/apollographql/apollo-engine-reporting",
"author": "Apollo <community@apollographql.com>",
"engines": {
"node": ">=6.0"
},
"dependencies": {
"apollo-server-env": "^2.0.0-rc.3",
"apollo-engine-reporting-protobuf": "0.0.0-beta.7",
"graphql-extensions": "^0.1.0-beta.15",
"lodash": "^4.17.10",
"requestretry": "^1.13.0"
},
"devDependencies": {
"@types/graphql": "^0.13.1",
"@types/jest": "^23.1.2",
"@types/lodash": "^4.14.110",
"@types/node-fetch": "^2.1.1",
"@types/requestretry": "^1.12.3",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"graphql-tools": "^3.0.4",
"jest": "^23.2.0",
"node-fetch": "^2.1.2",
"ts-jest": "^22.4.6",
"tslint": "^5.10.0"
},
"jest": {
"testEnvironment": "node",
"setupFiles": [
"<rootDir>/node_modules/apollo-server-env/dist/index.js"
],
"transform": {
"^.+\\.(ts|js)$": "ts-jest"
},
"moduleFileExtensions": [
"ts",
"js",
"json"
],
"testRegex": "/__tests__/.*$",
"globals": {
"ts-jest": {
"skipBabel": true
}
}
}
}
Loading