-
-
Save revmischa/0767c4b73d511e2881a7e6a9bdd820a9 to your computer and use it in GitHub Desktop.
AWS AppSync GraphQL scalars and directives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AWS AppSync GQL directives | |
# | |
## Scalars come from here: | |
# https://raw.githubusercontent.com/aws-amplify/amplify-cli/master/packages/amplify-graphql-types-generator/awsAppSyncDirectives.graphql | |
# https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html | |
# | |
## Directives came from a GitHub issue here: | |
# https://github.com/apollographql/eslint-plugin-graphql/issues/263 | |
## And comparing with the JSON output of | |
# https://docs.aws.amazon.com/appsync/latest/APIReference/API_GetIntrospectionSchema.html | |
# | |
scalar AWSDate | |
scalar AWSTime | |
scalar AWSDateTime | |
scalar AWSTimestamp | |
scalar AWSEmail | |
scalar AWSJSON | |
scalar AWSURL | |
scalar AWSPhone | |
scalar AWSIPAddress | |
""" | |
This directive allows results to be deferred during execution | |
""" | |
directive @defer on FIELD | |
""" | |
Tells the service this field/object has access authorized by an OIDC token. | |
""" | |
directive @aws_oidc on OBJECT | FIELD_DEFINITION | |
""" | |
Tells the service this field/object has access authorized by a Lambda Authorizer. | |
""" | |
directive @aws_lambda on FIELD_DEFINITION | OBJECT | |
""" | |
Directs the schema to enforce authorization on a field | |
""" | |
directive @aws_auth( | |
""" | |
List of cognito user pool groups which have access on this field | |
""" | |
cognito_groups: [String] | |
) on FIELD_DEFINITION | |
""" | |
Tells the service which subscriptions will be published to when this mutation is called. This directive is deprecated use @aws_susbscribe directive instead. | |
""" | |
directive @aws_publish( | |
""" | |
List of subscriptions which will be published to when this mutation is called. | |
""" | |
subscriptions: [String] | |
) on FIELD_DEFINITION | |
""" | |
Tells the service this field/object has access authorized by a Cognito User Pools token. | |
""" | |
directive @aws_cognito_user_pools( | |
""" | |
List of cognito user pool groups which have access on this field | |
""" | |
cognito_groups: [String] | |
) on OBJECT | FIELD_DEFINITION | INPUT_OBJECT | |
""" | |
Tells the service which mutation triggers this subscription. | |
""" | |
directive @aws_subscribe( | |
""" | |
List of mutations which will trigger this subscription when they are called. | |
""" | |
mutations: [String] | |
) on FIELD_DEFINITION | |
""" | |
Tells the service this field/object has access authorized by sigv4 signing. | |
""" | |
directive @aws_iam on OBJECT | FIELD_DEFINITION | INPUT_OBJECT | |
""" | |
Tells the service this field/object has access authorized by an API key. | |
""" | |
directive @aws_api_key on OBJECT | FIELD_DEFINITION | |
## Bonus directives for Amplify? | |
directive @auth(rules: [AuthRule!]!) repeatable on OBJECT | FIELD_DEFINITION | |
input AuthRule { | |
allow: AuthStrategy! | |
provider: AuthProvider | |
ownerField: String # defaults to "owner" when using owner auth | |
identityClaim: String # defaults to "username" when using owner auth | |
groupClaim: String # defaults to "cognito:groups" when using Group auth | |
groups: [String] # Required when using Static Group auth | |
groupsField: String # defaults to "groups" when using Dynamic Group auth | |
operations: [ModelOperation] # Required for finer control | |
# The following arguments are deprecated. It is encouraged to use the 'operations' argument. | |
queries: [ModelQuery] | |
mutations: [ModelMutation] | |
} | |
enum AuthStrategy { | |
owner | |
groups | |
private | |
public | |
} | |
enum AuthProvider { | |
apiKey | |
iam | |
oidc | |
userPools | |
} | |
enum ModelOperation { | |
create | |
update | |
delete | |
read | |
} | |
# The following objects are deprecated. It is encouraged to use ModelOperations. | |
enum ModelQuery { | |
get | |
list | |
} | |
enum ModelMutation { | |
create | |
update | |
delete | |
} | |
directive @connection(fields: [String!], keyName: String) repeatable on FIELD_DEFINITION | |
directive @key(fields: [String!], name: String!) repeatable on OBJECT | FIELD_DEFINITION | |
directive @model( | |
mutations: ModelMutationMap | |
queries: ModelQueryMap | |
subscriptions: ModelSubscriptionMap | |
timestamps: TimestampConfiguration | |
) repeatable on OBJECT | |
input ModelMutationMap { | |
create: String | |
update: String | |
delete: String | |
} | |
input ModelQueryMap { | |
get: String | |
list: String | |
} | |
input ModelSubscriptionMap { | |
onCreate: [String] | |
onUpdate: [String] | |
onDelete: [String] | |
level: ModelSubscriptionLevel | |
} | |
enum ModelSubscriptionLevel { | |
off | |
public | |
on | |
} | |
input TimestampConfiguration { | |
createdAt: String | |
updatedAt: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment