-
Notifications
You must be signed in to change notification settings - Fork 79
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
refactor: move directive definitions to a single source of truth #2342
Conversation
40e9298
to
13383ed
Compare
43b57f5
to
282c07d
Compare
@@ -64,7 +64,7 @@ export interface AuthDirective { | |||
} | |||
|
|||
// @public (undocumented) | |||
export const authDirectiveDefinition = "\n directive @auth(rules: [AuthRule!]!) on OBJECT | FIELD_DEFINITION\n input AuthRule {\n allow: AuthStrategy!\n provider: AuthProvider\n identityClaim: String\n groupClaim: String\n ownerField: String\n groupsField: String\n groups: [String]\n operations: [ModelOperation]\n }\n enum AuthStrategy {\n owner\n groups\n private\n public\n custom\n }\n enum AuthProvider {\n apiKey\n iam\n oidc\n userPools\n function\n }\n enum ModelOperation {\n create\n update\n delete\n read\n list\n get\n sync\n listen\n search\n }\n"; | |||
export const authDirectiveDefinition: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type is changing to string here, but the value is still the same.
6b9c874
to
e9b7109
Compare
75613ac
to
04d2aa7
Compare
943ea0c
to
4d9b06c
Compare
packages/amplify-graphql-directives/src/directives/app-sync/aws-api-key.ts
Outdated
Show resolved
Hide resolved
packages/amplify-graphql-directives/src/directives/v1/connection.ts
Outdated
Show resolved
Hide resolved
packages/amplify-graphql-directives/src/directives/v1/versioned.ts
Outdated
Show resolved
Hide resolved
packages/amplify-graphql-name-mapping-transformer/src/graphql-refers-to-transformer.ts
Outdated
Show resolved
Hide resolved
# Allows transformer libraries to deprecate directive arguments. | ||
directive @deprecated(reason: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ENUM | ENUM_VALUE | ||
`); | ||
export const EXTRA_DIRECTIVES_DOCUMENT = parse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find! I didn't see this when I was looking for definitions!
@@ -61,6 +61,7 @@ export const constructTransformerChain = (options?: TransformerFactoryArgs): Tra | |||
const indexTransformer = new IndexTransformer(); | |||
const hasOneTransformer = new HasOneTransformer(); | |||
|
|||
// The default list of transformers should match DefaultDirectives in packages/amplify-graphql-directives/src/index.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you're getting at, but this list doesn't match because we don't have transformers for the AppSync directives. A couple of things I can think of:
- Create new structures to house AppSync directives and Amplify directives, and compose
DefaultDirectives
from it and the list of Amplify directives - Include the list of supported AppSync directives in a comment so at least the number of directive definitions matches the number of transformer definitions
I slightly favor 1, but not enough to fight about it since we don't yet have any validation beyond somebody eyeballing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented option 1.
5be7b90
to
d9a2b41
Compare
Description of changes
Move directive definitions to a single source of truth. Transform logic will still be contained in the transformers. This change will allow codegen to depend the
@aws-amplify/graphql-directives
package and use the definitions as the default definitions of model generation.PR to use new package in codegen: aws-amplify/amplify-codegen#796
CDK / CloudFormation Parameters Changed
N/A
Issue #, if available
N/A
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.