Skip to content

Instantly share code, notes, and snippets.

@mbreslow
Created December 30, 2021 20:41
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbreslow/62531000b72e4ffe87bb62fe610aa72b to your computer and use it in GitHub Desktop.
Save mbreslow/62531000b72e4ffe87bb62fe610aa72b to your computer and use it in GitHub Desktop.
# I was running spectaql to generate documentation for my GraphQL API and it complained about
# directives that I had in my schema file. I threw errors including
# - Unknown directive "@model".
# - Unknown directive "@auth".
# - Unknown directive "@index".
# - Unknown directive "@hasOne".
# These are all directives you would use when developing an Amplify app.
#
# Created this file to include as the first schemaFile in specaql.yml so that the graphql
# parser is aware of the directives and can simply ignore them.
# https://docs.amplify.aws/cli-legacy/graphql-transformer/model/
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
}
# https://docs.amplify.aws/cli-legacy/graphql-transformer/key/
directive @key(fields: [String!]!, name: String, queryField: String) on OBJECT
# https://docs.amplify.aws/cli-legacy/graphql-transformer/auth/
# 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 "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 }
# https://docs.amplify.aws/cli-legacy/graphql-transformer/connection/
directive @connection(keyName: String, fields: [String!]) on FIELD_DEFINITION
# https://docs.amplify.aws/cli-legacy/graphql-transformer/function/
directive @function(name: String!, region: String) on FIELD_DEFINITION
# https://docs.amplify.aws/cli-legacy/graphql-transformer/http/
directive @http(method: HttpMethod, url: String!, headers: [HttpHeader]) on FIELD_DEFINITION
enum HttpMethod { PUT POST GET DELETE PATCH }
input HttpHeader {
key: String
value: String
}
# https://docs.amplify.aws/cli-legacy/graphql-transformer/predictions/
directive @predictions(actions: [PredictionsActions!]!) on FIELD_DEFINITION
enum PredictionsActions {
identifyText # uses Amazon Rekognition to detect text
identifyLabels # uses Amazon Rekognition to detect labels
convertTextToSpeech # uses Amazon Polly in a lambda to output a presigned url to synthesized speech
translateText # uses Amazon Translate to translate text from source to target language
}
# https://docs.amplify.aws/cli-legacy/graphql-transformer/searchable/
# Streams data from DynamoDB to OpenSearch and exposes search capabilities.
directive @searchable(queries: SearchableQueryMap) on OBJECT
input SearchableQueryMap { search: String }
# https://docs.amplify.aws/cli-legacy/graphql-transformer/versioned/
directive @versioned(versionField: String = "version", versionInput: String = "expectedVersion") on OBJECT
# https://npm.io/package/@aws-amplify/graphql-relational-transformer
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
# https://docs.amplify.aws/cli/graphql/data-modeling/#configure-a-primary-key
directive @index(name: String, queryField: String, sortKeyFields: [String!]) on FIELD_DEFINITION
# https://gialaboratory.github.io/report-results/reference
directive @aws_api_key on OBJECT | FIELD_DEFINITION
directive @aws_auth(cognito_groups: [String]) on FIELD_DEFINITION
directive @aws_cognito_user_pools(cognito_groups: [String]) on OBJECT | FIELD_DEFINITION
directive @aws_iam on OBJECT | FIELD_DEFINITION
directive @aws_lambda on OBJECT | FIELD_DEFINITION
directive @aws_oidc on OBJECT | FIELD_DEFINITION
directive @aws_publish(subscriptions: [String]) on FIELD_DEFINITION
directive @aws_subscribe(mutations: [String]) on FIELD_DEFINITION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment