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

[Federation] Allow specified directives during validation #2823

Merged
merged 4 commits into from Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/apollo-federation/CHANGELOG.md
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)
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
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