Skip to content

Commit

Permalink
Merge branch 'master' into EnforcingPrivateVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
Helen committed Jun 14, 2019
2 parents 293d4a3 + 4e4aa81 commit 8fc0a03
Show file tree
Hide file tree
Showing 34 changed files with 394 additions and 138 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### 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

- `apollo-engine-reporting-protobuf`: Update protobuff to include `forbiddenOperations` and `registeredOperations` [PR #2768](https://github.com/apollographql/apollo-server/pull/2768)
Expand Down
20 changes: 10 additions & 10 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.6"
"gatsby-theme-apollo-docs": "1.0.11"
}
}
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 docs/source/federation/advanced-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Organization {
}
```

> Note that although the fields argument is parsed as a selection set, some restrictions apply to make the result suitable as a key. For example, fields shouldn't return lists.
> Note that although the fields argument is parsed as a selection set, some restrictions apply to make the result suitable as a key. For example, fields shouldn't return unions or interfaces.
## Computed fields

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;
}
}


Expand Down Expand Up @@ -216,6 +210,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: 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 @@ -42,53 +42,6 @@ describe('keyFieldsSelectInvalidType', () => {
expect(warnings).toHaveLength(0);
});

it('warns if @key references fields of a list type', () => {
const serviceA = {
typeDefs: gql`
type Product @key(fields: "myList myOptionalList") {
sku: String!
myList: [String]!
myOptionalList: [String]
upc: String!
color: Color!
}
type Color {
id: ID!
value: String!
}
`,
name: 'serviceA',
};

const serviceB = {
typeDefs: gql`
extend type Product {
sku: String! @external
price: Int! @requires(fields: "sku")
}
`,
name: 'serviceB',
};

const { schema, errors } = composeServices([serviceA, serviceB]);
expect(errors).toHaveLength(0);

const warnings = validateKeyFieldsSelectInvalidType(schema);
expect(warnings).toMatchInlineSnapshot(`
Array [
Object {
"code": "KEY_FIELDS_SELECT_INVALID_TYPE",
"message": "[serviceA] Product -> A @key selects Product.myList, which is a list type. Keys cannot select lists.",
},
Object {
"code": "KEY_FIELDS_SELECT_INVALID_TYPE",
"message": "[serviceA] Product -> A @key selects Product.myOptionalList, which is a list type. Keys cannot select lists.",
},
]
`);
});

it('warns if @key references fields of an interface type', () => {
const serviceA = {
typeDefs: gql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
GraphQLSchema,
isObjectType,
FieldNode,
isListType,
isInterfaceType,
isNonNullType,
getNullableType,
Expand Down Expand Up @@ -46,19 +45,6 @@ export const keyFieldsSelectInvalidType = (schema: GraphQLSchema) => {
}

if (matchingField) {
if (
isListType(matchingField.type) ||
(isNonNullType(matchingField.type) &&
isListType(getNullableType(matchingField.type)))
) {
errors.push(
errorWithCode(
'KEY_FIELDS_SELECT_INVALID_TYPE',
logServiceAndType(serviceName, typeName) +
`A @key selects ${typeName}.${name}, which is a list type. Keys cannot select lists.`,
),
);
}
if (
isInterfaceType(matchingField.type) ||
(isNonNullType(matchingField.type) &&
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ export function buildFederatedSchema(
}),
);

// at this point in time, we have a schema to be printed into SDL which is
// At this point in time, we have a schema to be printed into SDL which is
// representative of what the user defined for their schema. This is before
// we process any of the federation directives and add custom federation types
// so its the right place to create our service definition sdl.
//
// we have to use a modified printSchema from graphql-js which includes support
// for preserving federation directives while removing them from the sdl
// We have to use a modified printSchema from graphql-js which includes
// support for preserving the *uses* of federation directives while removing
// their *definitions* from the sdl.
const sdl = printSchema(schema);

// Add an empty query root type if none has been defined
Expand Down
Loading

0 comments on commit 8fc0a03

Please sign in to comment.