Skip to content

Commit

Permalink
fix: don't migrate AppSync auth related directives (#8661)
Browse files Browse the repository at this point in the history
This commit prevents schemas with AppSync auth related directives
from being automatically migrated from transformer v1 to v2.
This is to prevent any unknown interactions between these directives
and the new auth.

Co-authored-by: Colin Ihrig <colihrig@amazon.com>
  • Loading branch information
cjihrig and cjihrig-aws committed Nov 4, 2021
1 parent 70547ad commit 903c7bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
Expand Up @@ -256,25 +256,4 @@ describe('Schema migration tests', () => {
migrateAndValidate(schema);
}).toThrow('Unknown directive "versioned".');
});

// TODO(cjihrig): This test is currently failing.
// it('AppSync directives are not migrated', () => {
// const schema1 = `
// type Todo @model @aws_api_key {
// id: ID!
// }`;

// expect(() => {
// migrateAndValidate(schema1);
// }).toThrow('Unknown directive "aws_api_key".');

// const schema2 = `
// type Todo @model @aws_iam {
// id: ID!
// }`;

// expect(() => {
// migrateAndValidate(schema2);
// }).toThrow('Unknown directive "aws_iam".');
// });
});
Expand Up @@ -21,3 +21,21 @@ test('deprecated @connection parameterization fails gracefully', async () => {
]
`);
});

test('AppSync auth directives are not migrated', async () => {
const denylist = ['aws_api_key', 'aws_iam', 'aws_oidc', 'aws_cognito_user_pools', 'aws_auth'];

for (const directive of denylist) {
const schema = `
type Todo @model @${directive} {
id: ID!
}`;
const result = await detectUnsupportedDirectives(schema);

expect(result).toMatchInlineSnapshot(`
Array [
"${directive}",
]
`);
}
});
Expand Up @@ -42,11 +42,6 @@ export async function detectUnsupportedDirectives(schema: string): Promise<Array
'model',
'function',
'predictions',
'aws_api_key',
'aws_iam',
'aws_oidc',
'aws_cognito_user_pools',
'aws_auth',
'aws_subscribe',
]);
const directiveMap: any = collectDirectivesByTypeNames(schema).types;
Expand Down

0 comments on commit 903c7bf

Please sign in to comment.