-
-
Save ashrocket/3039f848bbab2585e9de8aa6576d833a to your computer and use it in GitHub Desktop.
AWS AppSync GraphQL scalars and directives to support type completion and error checking in Webstorm IDEs
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
""" | |
This directive allows you to quickly & easily configure AWS Lambda resolvers within your AWS AppSync API. | |
https://docs.amplify.aws/cli-legacy/graphql-transformer/function/ | |
https://docs.amplify.aws/cli/graphql/custom-business-logic/#lambda-function-resolver | |
""" | |
directive @function(name: String!, region: String) on FIELD_DEFINITION | |
"""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 | |
"""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 | |
"""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 | |
""" | |
Tells the service this field/object has access authorized by an API key. | |
""" | |
directive @aws_api_key on OBJECT | FIELD_DEFINITION | |
# These are here to help the IDE recognise AWS types. | |
# | |
# Place this file outside the 'schema' directory so are not pushed to AWS, | |
# but are still picked up by Jetbrains's GraphQL plugin | |
# validate schemas. | |
# | |
# https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html | |
# | |
scalar AWSDateTime | |
scalar AWSDate | |
scalar AWSTime | |
scalar AWSTimestamp | |
scalar AWSEmail | |
scalar AWSJSON | |
scalar AWSURL | |
scalar AWSPhone | |
scalar AWSIPAddress | |
# https://docs.amplify.aws/cli/graphql/authorization-rules/#grant-lambda-function-access-to-graphql-api | |
# When applied to a type, augments the application with | |
# owner and group-based authorization rules. | |
directive @auth(rules: [AuthRule!]!) on OBJECT | FIELD_DEFINITION | |
input AuthRule { | |
allow: AuthStrategy! | |
provider: AuthProvider | |
ownerField: String # defaults to "owner" when using owner auth | |
identityClaim: String # defaults to "sub::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 | |
} | |
enum AuthStrategy { owner groups private public custom } | |
enum AuthProvider { apiKey iam oidc userPools function } | |
enum ModelOperation { | |
create | |
update | |
delete | |
read # Short-hand to allow "get", "list", "sync", "listen", and "search" | |
get # Retrieves an individual item | |
list # Retrieves a list of items | |
sync # Enables ability to sync offline/online changes (including via DataStore) | |
listen # Subscribes to real-time changes | |
search # Enables ability to search using @searchable directive | |
} | |
# https://docs.amplify.aws/cli/graphql/data-modeling/#model-directive | |
directive @model( | |
queries: ModelQueryMap | |
mutations: ModelMutationMap | |
subscriptions: ModelSubscriptionMap | |
timestamps: TimestampConfiguration | |
) 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 | |
} | |
directive @hasOne(fields: [String!]) on FIELD_DEFINITION | |
directive @hasMany(indexName: String, fields: [String!], limit: Int = 100) on FIELD_DEFINITION | |
directive @belongsTo(fields: [String!]) on FIELD_DEFINITION | |
directive @manyToMany(relationName: String!, limit: Int = 100) on FIELD_DEFINITION | |
directive @primaryKey(sortKeyFields: [String]) on FIELD_DEFINITION | |
directive @index(name: String, queryField: String, sortKeyFields: [String!]) on FIELD_DEFINITION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment