Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions src/__tests__/fixtures/schemas/merge-directives/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type Query {
getUser(id: ID!): User! @canonical
internalUser(id: ID!): User! @hidden
legacyUser(id: ID!): User! @renamed
}

type User @canonical {
id: ID!
name: String! @canonical
email: String! @hidden
oldField: String @renamed
}

type Post @hidden {
id: ID!
}

type Comment @renamed {
id: ID!
}
12 changes: 12 additions & 0 deletions src/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ describe('schema', () => {
`);
});

it('should accept merged-API directives on OBJECT and FIELD_DEFINITION', () => {
const api = new Api(
given.appSyncConfig({
schema: [
'src/__tests__/fixtures/schemas/merge-directives/schema.graphql',
],
}),
plugin,
);
expect(() => api.compileSchema()).not.toThrow();
});

it('should return single files schemas as-is', () => {
const api = new Api(given.appSyncConfig(), plugin);
const schema = new Schema(api, [
Expand Down
6 changes: 3 additions & 3 deletions src/resources/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ directive @aws_cognito_user_pools(
cognito_groups: [String]
) on FIELD_DEFINITION | OBJECT
directive @aws_subscribe(mutations: [String]) on FIELD_DEFINITION
directive @canonical on OBJECT
directive @hidden on OBJECT
directive @renamed on OBJECT
directive @canonical on OBJECT | FIELD_DEFINITION
directive @hidden on OBJECT | FIELD_DEFINITION
directive @renamed on OBJECT | FIELD_DEFINITION
scalar AWSDate
scalar AWSTime
scalar AWSDateTime
Expand Down