Skip to content

Commit

Permalink
Merge branch 'master' into passContextToLocalDataStore
Browse files Browse the repository at this point in the history
  • Loading branch information
James Baxley committed Jun 12, 2019
2 parents ad37d78 + 79fc259 commit a4db6d4
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### vNext

- `apollo-gateway`: Pass `context` through to the `graphql` command in `LocalGraphQLDatasource` `process` method [PR #2821](https://github.com/apollographql/apollo-server/pull/2821)
- `apollo-engine-reporting`: Set `forbiddenOperation` and `registeredOperation` later in the request lifecycle [PR #2828](https://github.com/apollographql/apollo-server/pull/2828)

### v2.6.2

Expand Down
6 changes: 3 additions & 3 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
},
"dependencies": {
"gatsby": "2.8.6",
"gatsby-theme-apollo-docs": "1.0.5"
"gatsby-theme-apollo-docs": "1.0.6"
}
}
2 changes: 1 addition & 1 deletion docs/source/features/unions-interfaces.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Unions and interfaces
description: How to write add unions and interfaces to a schema
description: How to add unions and interfaces to a schema
---

Unions and interfaces are great when you have fields that are in common between two types.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"compile:clean": "tsc --build tsconfig.build.json --clean",
"watch": "tsc --build tsconfig.build.json --watch",
"release": "npm run clean && npm ci && lerna publish --exact --include-merged-tags",
"release:server": "npm run release -- --force-publish=apollo-server,apollo-server-azure-functions,apollo-server-cloud-functions,apollo-server-cloudflare,apollo-server-express,apollo-server-fastify,apollo-server-hapi,apollo-server-koa,apollo-server-lambda,apollo-server-micro",
"release:server": "npm run release -- --force-publish=apollo-server,apollo-server-azure-functions,apollo-server-cloud-functions,apollo-server-cloudflare,apollo-server-express,apollo-server-fastify,apollo-server-hapi,apollo-server-koa,apollo-server-lambda,apollo-server-micro,apollo-server-testing,apollo-server-integration-testsuite",
"postinstall": "lerna run prepare && npm run compile",
"lint": "prettier-check '**/*.{js,ts}'",
"lint-fix": "prettier '**/*.{js,ts}' --write",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-engine-reporting/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-engine-reporting",
"version": "1.3.0",
"version": "1.3.1",
"description": "Send reports about your GraphQL services to Apollo Engine",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
10 changes: 4 additions & 6 deletions packages/apollo-engine-reporting/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@ export class EngineReportingExtension<TContext = any>
if (o.requestContext.metrics.persistedQueryRegister) {
this.trace.persistedQueryRegister = true;
}
if (o.requestContext.metrics.forbiddenOperation) {
this.trace.forbiddenOperation = true;
}
if (o.requestContext.metrics.registeredOperation) {
this.trace.registeredOperation = true;
}
}

if (this.options.privateVariables !== true && o.variables) {
Expand Down Expand Up @@ -204,6 +198,10 @@ export class EngineReportingExtension<TContext = any>

this.trace.fullQueryCacheHit = !!o.requestContext.metrics
.responseCacheHit;
this.trace.forbiddenOperation = !!o.requestContext.metrics
.forbiddenOperation;
this.trace.registeredOperation = !!o.requestContext.metrics
.registeredOperation;

// If the `operationName` was not already set elsewhere, for example,
// through the `executionDidStart` or the `willResolveField` hooks, then
Expand Down
2 changes: 2 additions & 0 deletions packages/apollo-federation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### vNEXT

* Allow specified directives during validation (@deprecated) [#2823](https://github.com/apollographql/apollo-server/pull/2823)

# v0.6.1

* Normalize SDL in a normalization step before validation [#2771](https://github.com/apollographql/apollo-server/pull/2771)
2 changes: 1 addition & 1 deletion packages/apollo-federation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/federation",
"version": "0.6.2",
"version": "0.6.3",
"description": "Apollo Federation Utilities",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ describe('keyFieldsMissingExternal', () => {
expect(warnings).toHaveLength(0);
});

it('has no warnings with @deprecated directive usage', () => {
const serviceA = {
typeDefs: gql`
extend type Car @key(fields: "model { name kit { upc } } year") {
model: Model! @external
year: String! @external
color: String! @deprecated(reason: "Use colors instead")
colors: Color!
}
extend type Model {
name: String! @external
kit: Kit @external
}
extend type Kit {
upc: String! @external
}
enum Color {
Red
Blue
}
`,
name: 'serviceA',
};

const warnings = validateKeyFieldsMissingExternal(serviceA);
expect(warnings).toHaveLength(0);
});

it("warns when a @key argument doesn't reference an @external field", () => {
const serviceA = {
typeDefs: gql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
parse,
GraphQLSchema,
GraphQLError,
specifiedDirectives,
} from 'graphql';
import { buildSchemaFromSDL } from 'apollo-graphql';
import { isNotNullOrUndefined } from 'apollo-env';
Expand Down Expand Up @@ -58,7 +59,7 @@ export const keyFieldsMissingExternal = ({
// this allows us to build a partial schema
let schema = new GraphQLSchema({
query: undefined,
directives: federationDirectives,
directives: [...specifiedDirectives, ...federationDirectives],
});
try {
schema = buildSchemaFromSDL(typeDefs, schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,61 @@ type Money {
`);
});

it('should preserve description text in generated SDL', async () => {
const query = `query GetServiceDetails {
_service {
sdl
}
}`;
const schema = buildFederatedSchema(gql`
"A user. This user is very complicated and requires so so so so so so so so so so so so so so so so so so so so so so so so so so so so so so so so much description text"
type User @key(fields: "id") {
"""
The unique ID of the user.
"""
id: ID!
"The user's name."
name: String
username: String
foo(
"Description 1"
arg1: String
"Description 2"
arg2: String
"Description 3 Description 3 Description 3 Description 3 Description 3 Description 3 Description 3 Description 3 Description 3 Description 3 Description 3"
arg3: String
): String
}
`);

const { data, errors } = await graphql(schema, query);
expect(errors).toBeUndefined();
expect(data._service.sdl).toEqual(`"""
A user. This user is very complicated and requires so so so so so so so so so so
so so so so so so so so so so so so so so so so so so so so so so much
description text
"""
type User @key(fields: "id") {
"The unique ID of the user."
id: ID!
"The user's name."
name: String
username: String
foo(
"Description 1"
arg1: String
"Description 2"
arg2: String
"""
Description 3 Description 3 Description 3 Description 3 Description 3
Description 3 Description 3 Description 3 Description 3 Description 3 Description 3
"""
arg3: String
): String
}
`);
});

describe(`should add an _entities query root field to the schema`, () => {
it(`when a query root type with the default name has been defined`, () => {
const schema = buildFederatedSchema(gql`
Expand Down
37 changes: 13 additions & 24 deletions packages/apollo-federation/src/service/printFederatedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ function printEnum(type: GraphQLEnumType): string {
const values = type
.getValues()
.map(
(value, i) =>
printDescription(value, ' ', !i) +
value =>
printDescription(value, ' ') +
' ' +
value.name +
printDeprecated(value),
Expand All @@ -232,7 +232,7 @@ function printEnum(type: GraphQLEnumType): string {

function printInputObject(type: GraphQLInputObjectType): string {
const fields = Object.values(type.getFields()).map(
(f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f),
f => printDescription(f, ' ') + ' ' + printInputValue(f),
);
return printDescription(type) + `input ${type.name}` + printBlock(fields);
}
Expand All @@ -241,8 +241,8 @@ function printFields(
type: GraphQLInterfaceType | GraphQLObjectType | GraphQLInputObjectType,
) {
const fields = Object.values(type.getFields()).map(
(f, i) =>
printDescription(f, ' ', !i) +
f =>
printDescription(f, ' ') +
' ' +
f.name +
printArgs(f.args, ' ') +
Expand Down Expand Up @@ -272,8 +272,8 @@ function printArgs(args: GraphQLArgument[], indentation = '') {
'(\n' +
args
.map(
(arg, i) =>
printDescription(arg, ' ' + indentation, !i) +
arg =>
printDescription(arg, ' ' + indentation) +
' ' +
indentation +
printInputValue(arg),
Expand Down Expand Up @@ -332,30 +332,19 @@ function printDescription(
| GraphQLEnumValue
| GraphQLUnionType,
indentation: string = '',
firstInBlock: boolean = true,
): string {
if (!def.description) {
return '';
}

const lines = descriptionLines(def.description, 120 - indentation.length);
return printDescriptionWithComments(lines, indentation, firstInBlock);
}

function printDescriptionWithComments(
lines: string[],
indentation: string,
firstInBlock: boolean,
) {
let description = indentation && !firstInBlock ? '\n' : '';
for (let i = 0; i < lines.length; i++) {
if (lines[i] === '') {
description += indentation + '#\n';
} else {
description += indentation + '# ' + lines[i] + '\n';
}
if (lines.length === 1) {
return indentation + `"${lines[0]}"\n`;
} else {
return (
indentation + ['"""', ...lines, '"""'].join('\n' + indentation) + '\n'
);
}
return description;
}

function descriptionLines(description: string, maxLen: number): Array<string> {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/gateway",
"version": "0.6.5",
"version": "0.6.6",
"description": "Apollo Gateway",
"author": "opensource@apollographql.com",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-azure-functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-azure-functions",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Azure Functions",
"keywords": [
"GraphQL",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-cloud-functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-cloud-functions",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Google Cloud Functions",
"keywords": [
"GraphQL",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-cloudflare",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Cloudflare workers",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-core",
"version": "2.6.2",
"version": "2.6.3",
"description": "Core engine for Apollo GraphQL server",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/requestPipelineAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class InvalidGraphQLRequestError extends Error {}
export type GraphQLExecutor<TContext = Record<string, any>> = (
requestContext: WithRequired<
GraphQLRequestContext<TContext>,
'document' | 'operationName' | 'operation'
'document' | 'operationName' | 'operation' | 'queryHash'
>,
) => ValueOrPromise<GraphQLExecutionResult>;

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-express",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Express and Connect",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-fastify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-fastify",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Fastify",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-hapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-hapi",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Hapi",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-integration-testsuite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "apollo-server-integration-testsuite",
"private": true,
"version": "2.6.2",
"version": "2.6.3",
"description": "Apollo Server Integrations testsuite",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-koa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-koa",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Koa",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-lambda/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-lambda",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for AWS Lambda",
"keywords": [
"GraphQL",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-micro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-server-micro",
"version": "2.6.2",
"version": "2.6.3",
"description": "Production-ready Node.js GraphQL server for Micro",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit a4db6d4

Please sign in to comment.