This package contains various utilities for definining GraphQl Apis via AppSync using the aws-cdk.
CodeFirstSchema
offers the ability to generate your schema in a code-first
approach. A code-first approach offers a developer workflow with:
- modularity: organizing schema type definitions into different files
- reusability: removing boilerplate/repetitive code
- consistency: resolvers and schema definition will always be synced
The code-first approach allows for dynamic schema generation. You can generate your schema based on variables and templates to reduce code duplication.
import { GraphqlApi } from '@aws-cdk/aws-appsync-alpha';
import { CodeFirstSchema } from 'awscdk-appsync-utils';
const schema = new CodeFirstSchema();
const api = new GraphqlApi(this, 'api', { name: 'myApi', schema });
schema.addType(new ObjectType('demo', {
definition: { id: GraphqlType.id() },
}));
To showcase the code-first approach. Let's try to model the following schema segment.
interface Node {
id: String
}
type Query {
allFilms(after: String, first: Int, before: String, last: Int): FilmConnection
}
type FilmNode implements Node {
filmName: String
}
type FilmConnection {
edges: [FilmEdge]
films: [Film]
totalCount: Int
}
type FilmEdge {
node: Film
cursor: String
}
Above we see a schema that allows for generating paginated responses. For example,
we can query allFilms(first: 100)
since FilmConnection
acts as an intermediary
for holding FilmEdges
we can write a resolver to return the first 100 films.
In a separate file, we can declare our object types and related functions.
We will call this file object-types.ts
and we will have created it in a way that
allows us to generate other XxxConnection
and XxxEdges
in the future.
import { GraphqlType, InterfaceType, ObjectType } from 'awscdk-appsync-utils';
const pluralize = require('pluralize');
export const args = {
after: GraphqlType.string(),
first: GraphqlType.int(),
before: GraphqlType.string(),
last: GraphqlType.int(),
};
export const Node = new InterfaceType('Node', {
definition: { id: GraphqlType.string() }
});
export const FilmNode = new ObjectType('FilmNode', {
interfaceTypes: [Node],
definition: { filmName: GraphqlType.string() }
});
export function generateEdgeAndConnection(base: ObjectType) {
const edge = new ObjectType(`${base.name}Edge`, {
definition: { node: base.attribute(), cursor: GraphqlType.string() }
});
const connection = new ObjectType(`${base.name}Connection`, {
definition: {
edges: edge.attribute({ isList: true }),
[pluralize(base.name)]: base.attribute({ isList: true }),
totalCount: GraphqlType.int(),
}
});
return { edge: edge, connection: connection };
}
Finally, we will go to our cdk-stack
and combine everything together
to generate our schema.
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const api = new appsync.GraphqlApi(this, 'Api', {
name: 'demo',
});
const objectTypes = [ Node, FilmNode ];
const filmConnections = generateEdgeAndConnection(FilmNode);
api.addQuery('allFilms', new ResolvableField({
returnType: filmConnections.connection.attribute(),
args: args,
dataSource: api.addNoneDataSource('none'),
requestMappingTemplate: dummyRequest,
responseMappingTemplate: dummyResponse,
}));
api.addType(Node);
api.addType(FilmNode);
api.addType(filmConnections.edge);
api.addType(filmConnections.connection);
Notice how we can utilize the generateEdgeAndConnection
function to generate
Object Types. In the future, if we wanted to create more Object Types, we can simply
create the base Object Type (i.e. Film) and from there we can generate its respective
Connections
and Edges
.
Check out a more in-depth example here.
One of the benefits of GraphQL is its strongly typed nature. We define the types within an object, query, mutation, interface, etc. as GraphQL Types.
GraphQL Types are the building blocks of types, whether they are scalar, objects, interfaces, etc. GraphQL Types can be:
- Scalar Types: Id, Int, String, AWSDate, etc.
- Object Types: types that you generate (i.e.
demo
from the example above) - Interface Types: abstract types that define the base implementation of other Intermediate Types
More concretely, GraphQL Types are simply the types appended to variables.
Referencing the object type Demo
in the previous example, the GraphQL Types
is String!
and is applied to both the names id
and version
.
Directives
are attached to a field or type and affect the execution of queries,
mutations, and types. With AppSync, we use Directives
to configure authorization.
Appsync utils provide static functions to add directives to your CodeFirstSchema.
Directive.iam()
sets a type or field's authorization to be validated throughIam
Directive.apiKey()
sets a type or field's authorization to be validated through aApi Key
Directive.oidc()
sets a type or field's authorization to be validated throughOpenID Connect
Directive.cognito(...groups: string[])
sets a type or field's authorization to be validated throughCognito User Pools
groups
the name of the cognito groups to give access
To learn more about authorization and directives, read these docs here.
While GraphqlType
is a base implementation for GraphQL fields, we have abstractions
on top of GraphqlType
that provide finer grain support.
Field
extends GraphqlType
and will allow you to define arguments. Interface Types are not resolvable and this class will allow you to define arguments,
but not its resolvers.
For example, if we want to create the following type:
type Node {
test(argument: string): String
}
The CDK code required would be:
import { Field, GraphqlType, InterfaceType } from 'awscdk-appsync-utils';
const field = new Field({
returnType: GraphqlType.string(),
args: {
argument: GraphqlType.string(),
},
});
const type = new InterfaceType('Node', {
definition: { test: field },
});
ResolvableField
extends Field
and will allow you to define arguments and its resolvers.
Object Types can have fields that resolve and perform operations on
your backend.
You can also create resolvable fields for object types.
type Info {
node(id: String): String
}
The CDK code required would be:
declare const api: appsync.GraphqlApi;
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const info = new ObjectType('Info', {
definition: {
node: new ResolvableField({
returnType: GraphqlType.string(),
args: {
id: GraphqlType.string(),
},
dataSource: api.addNoneDataSource('none'),
requestMappingTemplate: dummyRequest,
responseMappingTemplate: dummyResponse,
}),
},
});
To nest resolvers, we can also create top level query types that call upon other types. Building off the previous example, if we want the following graphql type definition:
type Query {
get(argument: string): Info
}
The CDK code required would be:
declare const api: appsync.GraphqlApi;
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const query = new ObjectType('Query', {
definition: {
get: new ResolvableField({
returnType: GraphqlType.string(),
args: {
argument: GraphqlType.string(),
},
dataSource: api.addNoneDataSource('none'),
requestMappingTemplate: dummyRequest,
responseMappingTemplate: dummyResponse,
}),
},
});
Learn more about fields and resolvers here.
Intermediate Types are defined by Graphql Types and Fields. They have a set of defined fields, where each field corresponds to another type in the system. Intermediate Types will be the meat of your GraphQL Schema as they are the types defined by you.
Intermediate Types include:
Interface Types are abstract types that define the implementation of other intermediate types. They are useful for eliminating duplication and can be used to generate Object Types with less work.
You can create Interface Types externally.
const node = new InterfaceType('Node', {
definition: {
id: GraphqlType.string({ isRequired: true }),
},
});
To learn more about Interface Types, read the docs here.
Object Types are types that you declare. For example, in the code-first example
the demo
variable is an Object Type. Object Types are defined by
GraphQL Types and are only usable when linked to a GraphQL Api.
You can create Object Types in two ways:
-
Object Types can be created externally.
const schema = new CodeFirstSchema(); const api = new appsync.GraphqlApi(this, 'Api', { name: 'demo', schema, }); const demo = new ObjectType('Demo', { definition: { id: GraphqlType.string({ isRequired: true }), version: GraphqlType.string({ isRequired: true }), }, }); schema.addType(demo);
This method allows for reusability and modularity, ideal for larger projects. For example, imagine moving all Object Type definition outside the stack.
object-types.ts
- a file for object type definitionsimport { ObjectType, GraphqlType } from 'awscdk-appsync-utils'; export const demo = new ObjectType('Demo', { definition: { id: GraphqlType.string({ isRequired: true }), version: GraphqlType.string({ isRequired: true }), }, });
cdk-stack.ts
- a file containing our cdk stackdeclare const schema: CodeFirstSchema; schema.addType(demo);
-
Object Types can be created externally from an Interface Type.
const node = new InterfaceType('Node', { definition: { id: GraphqlType.string({ isRequired: true }), }, }); const demo = new ObjectType('Demo', { interfaceTypes: [ node ], definition: { version: GraphqlType.string({ isRequired: true }), }, });
This method allows for reusability and modularity, ideal for reducing code duplication.
To learn more about Object Types, read the docs here.
Enum Types are a special type of Intermediate Type. They restrict a particular set of allowed values for other Intermediate Types.
enum Episode {
NEWHOPE
EMPIRE
JEDI
}
This means that wherever we use the type Episode in our schema, we expect it to be exactly one of NEWHOPE, EMPIRE, or JEDI.
The above GraphQL Enumeration Type can be expressed in CDK as the following:
declare const api: GraphqlApi;
const episode = new EnumType('Episode', {
definition: [
'NEWHOPE',
'EMPIRE',
'JEDI',
],
});
api.addType(episode);
To learn more about Enum Types, read the docs here.
Input Types are special types of Intermediate Types. They give users an easy way to pass complex objects for top level Mutation and Queries.
input Review {
stars: Int!
commentary: String
}
The above GraphQL Input Type can be expressed in CDK as the following:
declare const api: appsync.GraphqlApi;
const review = new InputType('Review', {
definition: {
stars: GraphqlType.int({ isRequired: true }),
commentary: GraphqlType.string(),
},
});
api.addType(review);
To learn more about Input Types, read the docs here.
Union Types are a special type of Intermediate Type. They are similar to Interface Types, but they cannot specify any common fields between types.
Note: the fields of a union type need to be Object Types
. In other words, you
can't create a union type out of interfaces, other unions, or inputs.
union Search = Human | Droid | Starship
The above GraphQL Union Type encompasses the Object Types of Human, Droid and Starship. It can be expressed in CDK as the following:
declare const api: appsync.GraphqlApi;
const string = GraphqlType.string();
const human = new ObjectType('Human', { definition: { name: string } });
const droid = new ObjectType('Droid', { definition: { name: string } });
const starship = new ObjectType('Starship', { definition: { name: string } }););
const search = new UnionType('Search', {
definition: [ human, droid, starship ],
});
api.addType(search);
To learn more about Union Types, read the docs here.
Every schema requires a top level Query type. By default, the schema will look
for the Object Type
named Query
. The top level Query
is the only exposed
type that users can access to perform GET
operations on your Api.
To add fields for these queries, we can simply run the addQuery
function to add
to the schema's Query
type.
declare const api: appsync.GraphqlApi;
declare const filmConnection: InterfaceType;
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const string = GraphqlType.string();
const int = GraphqlType.int();
api.addQuery('allFilms', new ResolvableField({
returnType: filmConnection.attribute(),
args: { after: string, first: int, before: string, last: int},
dataSource: api.addNoneDataSource('none'),
requestMappingTemplate: dummyRequest,
responseMappingTemplate: dummyResponse,
}));
To learn more about top level operations, check out the docs here.
Every schema can have a top level Mutation type. By default, the schema will look
for the ObjectType
named Mutation
. The top level Mutation
Type is the only exposed
type that users can access to perform mutable
operations on your Api.
To add fields for these mutations, we can simply run the addMutation
function to add
to the schema's Mutation
type.
declare const api: appsync.GraphqlApi;
declare const filmNode: ObjectType;
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const string = GraphqlType.string();
const int = GraphqlType.int();
api.addMutation('addFilm', new ResolvableField({
returnType: filmNode.attribute(),
args: { name: string, film_number: int },
dataSource: api.addNoneDataSource('none'),
requestMappingTemplate: dummyRequest,
responseMappingTemplate: dummyResponse,
}));
To learn more about top level operations, check out the docs here.
Every schema can have a top level Subscription type. The top level Subscription
Type
is the only exposed type that users can access to invoke a response to a mutation. Subscriptions
notify users when a mutation specific mutation is called. This means you can make any data source
real time by specify a GraphQL Schema directive on a mutation.
Note: The AWS AppSync client SDK automatically handles subscription connection management.
To add fields for these subscriptions, we can simply run the addSubscription
function to add
to the schema's Subscription
type.
declare const api: appsync.GraphqlApi;
declare const film: InterfaceType;
api.addSubscription('addedFilm', new Field({
returnType: film.attribute(),
args: { id: GraphqlType.id({ isRequired: true }) },
directives: [Directive.subscribe('addFilm')],
}));
To learn more about top level operations, check out the docs here.
The SourceApiAssociationMergeOperation construct provides the ability to merge a source api to a Merged Api and invoke a merge within a Cloudformation custom resource. If the merge operation fails with a conflict, the Cloudformation update will fail and rollback the changes to the source API in the stack.
import * as cdk from 'aws-cdk-lib';
const sourceApi1ToMerge = new appsync.GraphqlApi(this, 'FirstSourceAPI', {
name: 'FirstSourceAPI',
definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.merged-api-1.graphql')),
});
const sourceApi2ToMerge = new appsync.GraphqlApi(this, 'SecondSourceAPI', {
name: 'SecondSourceAPI',
definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.merged-api-2.graphql')),
});
const remoteMergedApi = appsync.GraphqlApi.fromGraphqlApiAttributes(this, 'ImportedMergedApi', {
graphqlApiId: 'MyApiId',
graphqlApiArn: 'MyApiArn',
});
const remoteExecutionRole = iam.Role.fromRoleArn(this, 'ExecutionRole', 'arn:aws:iam::ACCOUNT:role/MyExistingRole');
const association1 = new appsync.SourceApiAssociation(this, 'SourceApiAssociation1', {
sourceApi: sourceApi1ToMerge,
mergedApi: remoteMergedApi,
mergeType: appsync.MergeType.MANUAL_MERGE,
mergedApiExecutionRole: remoteExecutionRole,
});
const association2 = new appsync.SourceApiAssociation(this, 'SourceApiAssociation2', {
sourceApi: sourceApi2ToMerge,
mergedApi: remoteMergedApi,
mergeType: appsync.MergeType.MANUAL_MERGE,
mergedApiExecutionRole: remoteExecutionRole,
});
// The version id can be any identifier defined by the developer. Changing the version identifier allows you to control
// whether a merge operation will take place during deployment.
SourceApiAssociationMergeOperation(this, 'MergeOperation1', {
sourceApiAssociation: association1,
versionIdentifier: '1',
});
// Optionally, you can add the alwaysMergeOnStackUpdate flag instead which will ensure that the merge operation occurs
// during every stack update, regardless if there was a change or not. Note that this may lead to merge operations that
//do not actually change the MergedAPI.
SourceApiAssociationMergeOperation(this, 'MergeOperation2', {
sourceApiAssociation: association2,
alwaysMergeOnStackUpdate: true,
});
This library leans towards high level and experimental features for appsync cdk users. If you have an idea for additional utilities please create an issue describing the feature.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.
The SourceApiAssociationMergeOperation triggers a merge of a source API during a Cloudformation stack update.
This can be used to propagate changes from the source API to the Merged API when the association is using type MANUAL_MERGE. If the merge operation fails, it will fail the Cloudformation update and rollback the stack.
import { SourceApiAssociationMergeOperation } from 'awscdk-appsync-utils'
new SourceApiAssociationMergeOperation(scope: Construct, id: string, props: SourceApiAssociationMergeOperationProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SourceApiAssociationMergeOperationProps |
No description. |
- Type: constructs.Construct
- Type: string
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { SourceApiAssociationMergeOperation } from 'awscdk-appsync-utils'
SourceApiAssociationMergeOperation.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
- Implements: ISourceApiAssociationMergeOperationProvider
SourceApiAssociationMergeProvider class is responsible for constructing the custom resource that will be used for initiating the source API merge during a Cloudformation update.
import { SourceApiAssociationMergeOperationProvider } from 'awscdk-appsync-utils'
new SourceApiAssociationMergeOperationProvider(scope: Construct, id: string, props: SourceApiAssociationMergeOperationProviderProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SourceApiAssociationMergeOperationProviderProps |
No description. |
- Type: constructs.Construct
- Type: string
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
associateSourceApiAssociation |
This function associates a source api association with the provider. |
public toString(): string
Returns a string representation of this construct.
public associateSourceApiAssociation(sourceApiAssociation: ISourceApiAssociation): void
This function associates a source api association with the provider.
This method can be used for adding permissions to merge a specific source api association to the custom resource provider.
- Type: aws-cdk-lib.aws_appsync.ISourceApiAssociation
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { SourceApiAssociationMergeOperationProvider } from 'awscdk-appsync-utils'
SourceApiAssociationMergeOperationProvider.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
schemaMergeLambda |
aws-cdk-lib.aws_lambda.SingletonFunction |
The lambda function responsible for kicking off the merge operation. |
serviceToken |
string |
Service token for the resource provider. |
sourceApiStablizationLambda |
aws-cdk-lib.aws_lambda.SingletonFunction |
The lambda function response for ensuring that the merge operation finished. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly schemaMergeLambda: SingletonFunction;
- Type: aws-cdk-lib.aws_lambda.SingletonFunction
The lambda function responsible for kicking off the merge operation.
public readonly serviceToken: string;
- Type: string
Service token for the resource provider.
public readonly sourceApiStablizationLambda: SingletonFunction;
- Type: aws-cdk-lib.aws_lambda.SingletonFunction
The lambda function response for ensuring that the merge operation finished.
The options to add a field to an Intermediate Type.
import { AddFieldOptions } from 'awscdk-appsync-utils'
const addFieldOptions: AddFieldOptions = { ... }
Name | Type | Description |
---|---|---|
field |
IField |
The resolvable field to add. |
fieldName |
string |
The name of the field. |
public readonly field: IField;
- Type: IField
- Default: no IField
The resolvable field to add.
This option must be configured for Object, Interface, Input and Union Types.
public readonly fieldName: string;
- Type: string
- Default: no fieldName
The name of the field.
This option must be configured for Object, Interface, Input and Enum Types.
Base options for GraphQL Types.
import { BaseTypeOptions } from 'awscdk-appsync-utils'
const baseTypeOptions: BaseTypeOptions = { ... }
Name | Type | Description |
---|---|---|
isList |
boolean |
property determining if this attribute is a list i.e. if true, attribute would be [Type]. |
isRequired |
boolean |
property determining if this attribute is non-nullable i.e. if true, attribute would be Type! |
isRequiredList |
boolean |
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! or if isRequired true, attribe would be [ Type! ]! |
public readonly isList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a list i.e. if true, attribute would be [Type].
public readonly isRequired: boolean;
- Type: boolean
- Default: false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
public readonly isRequiredList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! or if isRequired true, attribe would be [ Type! ]!
Properties for configuring an Enum Type.
import { EnumTypeOptions } from 'awscdk-appsync-utils'
const enumTypeOptions: EnumTypeOptions = { ... }
Name | Type | Description |
---|---|---|
definition |
string[] |
the attributes of this type. |
public readonly definition: string[];
- Type: string[]
the attributes of this type.
Properties for configuring a field.
import { FieldOptions } from 'awscdk-appsync-utils'
const fieldOptions: FieldOptions = { ... }
Name | Type | Description |
---|---|---|
returnType |
GraphqlType |
The return type for this field. |
args |
{[ key: string ]: GraphqlType} |
The arguments for this field. |
directives |
Directive[] |
the directives for this field. |
public readonly returnType: GraphqlType;
- Type: GraphqlType
The return type for this field.
public readonly args: {[ key: string ]: GraphqlType};
- Type: {[ key: string ]: GraphqlType}
- Default: no arguments
The arguments for this field.
i.e. type Example (first: String second: String) {}
- where 'first' and 'second' are key values for args and 'String' is the GraphqlType
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this field.
Options for GraphQL Types.
import { GraphqlTypeOptions } from 'awscdk-appsync-utils'
const graphqlTypeOptions: GraphqlTypeOptions = { ... }
Name | Type | Description |
---|---|---|
isList |
boolean |
property determining if this attribute is a list i.e. if true, attribute would be [Type]. |
isRequired |
boolean |
property determining if this attribute is non-nullable i.e. if true, attribute would be Type! |
isRequiredList |
boolean |
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! or if isRequired true, attribe would be [ Type! ]! |
intermediateType |
IIntermediateType |
the intermediate type linked to this attribute. |
public readonly isList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a list i.e. if true, attribute would be [Type].
public readonly isRequired: boolean;
- Type: boolean
- Default: false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
public readonly isRequiredList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! or if isRequired true, attribe would be [ Type! ]!
public readonly intermediateType: IIntermediateType;
- Type: IIntermediateType
- Default: no intermediate type
the intermediate type linked to this attribute.
Properties for configuring an Intermediate Type.
import { IntermediateTypeOptions } from 'awscdk-appsync-utils'
const intermediateTypeOptions: IntermediateTypeOptions = { ... }
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
directives |
Directive[] |
the directives for this object type. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this object type.
Properties for configuring an Object Type.
import { ObjectTypeOptions } from 'awscdk-appsync-utils'
const objectTypeOptions: ObjectTypeOptions = { ... }
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
directives |
Directive[] |
the directives for this object type. |
interfaceTypes |
InterfaceType[] |
The Interface Types this Object Type implements. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this object type.
public readonly interfaceTypes: InterfaceType[];
- Type: InterfaceType[]
- Default: no interface types
The Interface Types this Object Type implements.
Properties for configuring a resolvable field.
import { ResolvableFieldOptions } from 'awscdk-appsync-utils'
const resolvableFieldOptions: ResolvableFieldOptions = { ... }
Name | Type | Description |
---|---|---|
returnType |
GraphqlType |
The return type for this field. |
args |
{[ key: string ]: GraphqlType} |
The arguments for this field. |
directives |
Directive[] |
the directives for this field. |
dataSource |
aws-cdk-lib.aws_appsync.BaseDataSource |
The data source creating linked to this resolvable field. |
pipelineConfig |
aws-cdk-lib.aws_appsync.IAppsyncFunction[] |
configuration of the pipeline resolver. |
requestMappingTemplate |
aws-cdk-lib.aws_appsync.MappingTemplate |
The request mapping template for this resolver. |
responseMappingTemplate |
aws-cdk-lib.aws_appsync.MappingTemplate |
The response mapping template for this resolver. |
public readonly returnType: GraphqlType;
- Type: GraphqlType
The return type for this field.
public readonly args: {[ key: string ]: GraphqlType};
- Type: {[ key: string ]: GraphqlType}
- Default: no arguments
The arguments for this field.
i.e. type Example (first: String second: String) {}
- where 'first' and 'second' are key values for args and 'String' is the GraphqlType
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this field.
public readonly dataSource: BaseDataSource;
- Type: aws-cdk-lib.aws_appsync.BaseDataSource
- Default: no data source
The data source creating linked to this resolvable field.
public readonly pipelineConfig: IAppsyncFunction[];
- Type: aws-cdk-lib.aws_appsync.IAppsyncFunction[]
- Default: no pipeline resolver configuration An empty array or undefined prop will set resolver to be of type unit
configuration of the pipeline resolver.
public readonly requestMappingTemplate: MappingTemplate;
- Type: aws-cdk-lib.aws_appsync.MappingTemplate
- Default: No mapping template
The request mapping template for this resolver.
public readonly responseMappingTemplate: MappingTemplate;
- Type: aws-cdk-lib.aws_appsync.MappingTemplate
- Default: No mapping template
The response mapping template for this resolver.
Properties for SourceApiAssociationMergeOperation which handles triggering a merge operation as a custom resource during a Cloudformation stack update.
import { SourceApiAssociationMergeOperationProps } from 'awscdk-appsync-utils'
const sourceApiAssociationMergeOperationProps: SourceApiAssociationMergeOperationProps = { ... }
Name | Type | Description |
---|---|---|
sourceApiAssociation |
aws-cdk-lib.aws_appsync.ISourceApiAssociation |
The source api association resource which will be merged. |
alwaysMergeOnStackUpdate |
boolean |
Flag indicating whether the source api should be merged on every CFN update or not. |
mergeOperationProvider |
ISourceApiAssociationMergeOperationProvider |
The merge operation provider construct which is responsible for configuring the Lambda resource that will be invoked during Cloudformation update. |
versionIdentifier |
string |
The version identifier for the schema merge operation. |
public readonly sourceApiAssociation: ISourceApiAssociation;
- Type: aws-cdk-lib.aws_appsync.ISourceApiAssociation
The source api association resource which will be merged.
public readonly alwaysMergeOnStackUpdate: boolean;
- Type: boolean
- Default: False
Flag indicating whether the source api should be merged on every CFN update or not.
If set to true and there are no changes to the source API, this will result in a no-op merge operation.
public readonly mergeOperationProvider: ISourceApiAssociationMergeOperationProvider;
The merge operation provider construct which is responsible for configuring the Lambda resource that will be invoked during Cloudformation update.
public readonly versionIdentifier: string;
- Type: string
- Default: null
The version identifier for the schema merge operation.
Any change to the version identifier will trigger a merge on the next update. Use the version identifier property to control when the source API metadata is merged.
Properties for SourceApiAssociationMergeOperationProvider.
import { SourceApiAssociationMergeOperationProviderProps } from 'awscdk-appsync-utils'
const sourceApiAssociationMergeOperationProviderProps: SourceApiAssociationMergeOperationProviderProps = { ... }
Name | Type | Description |
---|---|---|
pollingInterval |
aws-cdk-lib.Duration |
Time between calls to the polling Lambda function which determines whether the merge operation is finished or not. |
totalTimeout |
aws-cdk-lib.Duration |
Total timeout in waiting for the source api association merge operation to complete. |
public readonly pollingInterval: Duration;
- Type: aws-cdk-lib.Duration
- Default: Duration.seconds(5)
Time between calls to the polling Lambda function which determines whether the merge operation is finished or not.
public readonly totalTimeout: Duration;
- Type: aws-cdk-lib.Duration
- Default: Duration.minutes(15)
Total timeout in waiting for the source api association merge operation to complete.
Properties for configuring an Union Type.
import { UnionTypeOptions } from 'awscdk-appsync-utils'
const unionTypeOptions: UnionTypeOptions = { ... }
Name | Type | Description |
---|---|---|
definition |
IIntermediateType[] |
the object types for this union type. |
public readonly definition: IIntermediateType[];
- Type: IIntermediateType[]
the object types for this union type.
- Implements: aws-cdk-lib.aws_appsync.ISchema
import { CodeFirstSchema } from 'awscdk-appsync-utils'
new CodeFirstSchema()
Name | Type | Description |
---|
Name | Description |
---|---|
addMutation |
Add a mutation field to the schema's Mutation. CDK will create an Object Type called 'Mutation'. For example,. |
addQuery |
Add a query field to the schema's Query. CDK will create an Object Type called 'Query'. For example,. |
addSubscription |
Add a subscription field to the schema's Subscription. CDK will create an Object Type called 'Subscription'. For example,. |
addToSchema |
Escape hatch to add to Schema as desired. |
addType |
Add type to the schema. |
bind |
Called when the GraphQL Api is initialized to allow this object to bind to the stack. |
public addMutation(fieldName: string, field: ResolvableField): ObjectType
Add a mutation field to the schema's Mutation. CDK will create an Object Type called 'Mutation'. For example,.
type Mutation { fieldName: Field.returnType }
- Type: string
the name of the Mutation.
- Type: ResolvableField
the resolvable field to for this Mutation.
public addQuery(fieldName: string, field: ResolvableField): ObjectType
Add a query field to the schema's Query. CDK will create an Object Type called 'Query'. For example,.
type Query { fieldName: Field.returnType }
- Type: string
the name of the query.
- Type: ResolvableField
the resolvable field to for this query.
public addSubscription(fieldName: string, field: Field): ObjectType
Add a subscription field to the schema's Subscription. CDK will create an Object Type called 'Subscription'. For example,.
type Subscription { fieldName: Field.returnType }
- Type: string
the name of the Subscription.
- Type: Field
the resolvable field to for this Subscription.
public addToSchema(addition: string, delimiter?: string): void
Escape hatch to add to Schema as desired.
Will always result in a newline.
- Type: string
the addition to add to schema.
- Type: string
the delimiter between schema and addition.
public addType(type: IIntermediateType): IIntermediateType
Add type to the schema.
- Type: IIntermediateType
the intermediate type to add to the schema.
public bind(api: IGraphqlApi, _options?: SchemaBindOptions): ISchemaConfig
Called when the GraphQL Api is initialized to allow this object to bind to the stack.
- Type: aws-cdk-lib.aws_appsync.IGraphqlApi
The binding GraphQL Api.
- Type: aws-cdk-lib.aws_appsync.SchemaBindOptions
Name | Type | Description |
---|---|---|
definition |
string |
The definition for this schema. |
public readonly definition: string;
- Type: string
The definition for this schema.
Directives for types.
i.e. @aws_iam or @aws_subscribe
Name | Description |
---|---|
toString |
Generate the directive statement. |
public toString(): string
Generate the directive statement.
Name | Description |
---|---|
apiKey |
Add the @aws_api_key directive. |
cognito |
Add the @aws_auth or @aws_cognito_user_pools directive. |
custom |
Add a custom directive. |
iam |
Add the @aws_iam directive. |
oidc |
Add the @aws_oidc directive. |
subscribe |
Add the @aws_subscribe directive. |
import { Directive } from 'awscdk-appsync-utils'
Directive.apiKey()
Add the @aws_api_key directive.
import { Directive } from 'awscdk-appsync-utils'
Directive.cognito(groups: string)
Add the @aws_auth or @aws_cognito_user_pools directive.
- Type: string
the groups to allow access to.
import { Directive } from 'awscdk-appsync-utils'
Directive.custom(statement: string)
Add a custom directive.
- Type: string
the directive statement to append.
import { Directive } from 'awscdk-appsync-utils'
Directive.iam()
Add the @aws_iam directive.
import { Directive } from 'awscdk-appsync-utils'
Directive.oidc()
Add the @aws_oidc directive.
import { Directive } from 'awscdk-appsync-utils'
Directive.subscribe(mutations: string)
Add the @aws_subscribe directive.
Only use for top level Subscription type.
- Type: string
the mutation fields to link to.
Name | Type | Description |
---|---|---|
mode |
aws-cdk-lib.aws_appsync.AuthorizationType |
The authorization type of this directive. |
mutationFields |
string[] |
Mutation fields for a subscription directive. |
public readonly mode: AuthorizationType;
- Type: aws-cdk-lib.aws_appsync.AuthorizationType
- Default: not an authorization directive
The authorization type of this directive.
public readonly mutationFields: string[];
- Type: string[]
- Default: not a subscription directive
Mutation fields for a subscription directive.
- Implements: IIntermediateType
Enum Types are abstract types that includes a set of fields that represent the strings this type can create.
import { EnumType } from 'awscdk-appsync-utils'
new EnumType(name: string, options: EnumTypeOptions)
Name | Type | Description |
---|---|---|
name |
string |
No description. |
options |
EnumTypeOptions |
No description. |
- Type: string
- Type: EnumTypeOptions
Name | Description |
---|---|
addField |
Add a field to this Enum Type. |
attribute |
Create an GraphQL Type representing this Enum Type. |
toString |
Generate the string of this enum type. |
public addField(options: AddFieldOptions): void
Add a field to this Enum Type.
To add a field to this Enum Type, you must only configure addField with the fieldName options.
- Type: AddFieldOptions
the options to add a field.
public attribute(options?: BaseTypeOptions): GraphqlType
Create an GraphQL Type representing this Enum Type.
- Type: BaseTypeOptions
public toString(): string
Generate the string of this enum type.
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
name |
string |
the name of this type. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly name: string;
- Type: string
the name of this type.
- Implements: IField
Fields build upon Graphql Types and provide typing and arguments.
import { Field } from 'awscdk-appsync-utils'
new Field(options: FieldOptions)
Name | Type | Description |
---|---|---|
options |
FieldOptions |
No description. |
- Type: FieldOptions
Name | Description |
---|---|
argsToString |
Generate the args string of this resolvable field. |
directivesToString |
Generate the directives for this field. |
toString |
Generate the string for this attribute. |
public argsToString(): string
Generate the args string of this resolvable field.
public directivesToString(modes?: AuthorizationType[]): string
Generate the directives for this field.
- Type: aws-cdk-lib.aws_appsync.AuthorizationType[]
public toString(): string
Generate the string for this attribute.
Name | Description |
---|---|
awsDate |
AWSDate scalar type represents a valid extended ISO 8601 Date string. |
awsDateTime |
AWSDateTime scalar type represents a valid extended ISO 8601 DateTime string. |
awsEmail |
AWSEmail scalar type represents an email address string (i.e.[email protected] ). |
awsIpAddress |
AWSIPAddress scalar type respresents a valid IPv4 of IPv6 address string. |
awsJson |
AWSJson scalar type represents a JSON string. |
awsPhone |
AWSPhone scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated. |
awsTime |
AWSTime scalar type represents a valid extended ISO 8601 Time string. |
awsTimestamp |
AWSTimestamp scalar type represents the number of seconds since 1970-01-01T00:00Z . |
awsUrl |
AWSURL scalar type represetns a valid URL string. |
boolean |
Boolean scalar type is a boolean value: true or false. |
float |
Float scalar type is a signed double-precision fractional value. |
id |
ID scalar type is a unique identifier. ID type is serialized similar to String . |
int |
Int scalar type is a signed non-fractional numerical value. |
intermediate |
an intermediate type to be added as an attribute (i.e. an interface or an object type). |
string |
String scalar type is a free-form human-readable text. |
import { Field } from 'awscdk-appsync-utils'
Field.awsDate(options?: BaseTypeOptions)
AWSDate
scalar type represents a valid extended ISO 8601 Date
string.
In other words, accepts date strings in the form of YYYY-MM-DD
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsDateTime(options?: BaseTypeOptions)
AWSDateTime
scalar type represents a valid extended ISO 8601 DateTime
string.
In other words, accepts date strings in the form of YYYY-MM-DDThh:mm:ss.sssZ
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsEmail(options?: BaseTypeOptions)
AWSEmail
scalar type represents an email address string (i.e.[email protected]
).
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsIpAddress(options?: BaseTypeOptions)
AWSIPAddress
scalar type respresents a valid IPv4
of IPv6
address string.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsJson(options?: BaseTypeOptions)
AWSJson
scalar type represents a JSON string.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsPhone(options?: BaseTypeOptions)
AWSPhone
scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated.
The number can specify a country code at the beginning, but is not required for US phone numbers.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsTime(options?: BaseTypeOptions)
AWSTime
scalar type represents a valid extended ISO 8601 Time
string.
In other words, accepts date strings in the form of hh:mm:ss.sss
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsTimestamp(options?: BaseTypeOptions)
AWSTimestamp
scalar type represents the number of seconds since 1970-01-01T00:00Z
.
Timestamps are serialized and deserialized as numbers.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.awsUrl(options?: BaseTypeOptions)
AWSURL
scalar type represetns a valid URL string.
URLs wihtout schemes or contain double slashes are considered invalid.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.boolean(options?: BaseTypeOptions)
Boolean
scalar type is a boolean value: true or false.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.float(options?: BaseTypeOptions)
Float
scalar type is a signed double-precision fractional value.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.id(options?: BaseTypeOptions)
ID
scalar type is a unique identifier. ID
type is serialized similar to String
.
Often used as a key for a cache and not intended to be human-readable.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.int(options?: BaseTypeOptions)
Int
scalar type is a signed non-fractional numerical value.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { Field } from 'awscdk-appsync-utils'
Field.intermediate(options?: GraphqlTypeOptions)
an intermediate type to be added as an attribute (i.e. an interface or an object type).
- Type: GraphqlTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList - intermediateType.
import { Field } from 'awscdk-appsync-utils'
Field.string(options?: BaseTypeOptions)
String
scalar type is a free-form human-readable text.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
Name | Type | Description |
---|---|---|
isList |
boolean |
property determining if this attribute is a list i.e. if true, attribute would be [Type] . |
isRequired |
boolean |
property determining if this attribute is non-nullable i.e. if true, attribute would be Type! and this attribute must always have a value. |
isRequiredList |
boolean |
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! and this attribute's list must always have a value. |
type |
Type |
the type of attribute. |
intermediateType |
IIntermediateType |
the intermediate type linked to this attribute (i.e. an interface or an object). |
fieldOptions |
ResolvableFieldOptions |
The options for this field. |
public readonly isList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a list i.e. if true, attribute would be [Type]
.
public readonly isRequired: boolean;
- Type: boolean
- Default: false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
and this attribute must always have a value.
public readonly isRequiredList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]!
and this attribute's list must always have a value.
public readonly type: Type;
- Type: Type
the type of attribute.
public readonly intermediateType: IIntermediateType;
- Type: IIntermediateType
- Default: no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
public readonly fieldOptions: ResolvableFieldOptions;
- Type: ResolvableFieldOptions
- Default: no arguments
The options for this field.
- Implements: IField
The GraphQL Types in AppSync's GraphQL.
GraphQL Types are the building blocks for object types, queries, mutations, etc. They are types like String, Int, Id or even Object Types you create.
i.e. String
, String!
, [String]
, [String!]
, [String]!
GraphQL Types are used to define the entirety of schema.
import { GraphqlType } from 'awscdk-appsync-utils'
new GraphqlType(type: Type, options?: GraphqlTypeOptions)
Name | Type | Description |
---|---|---|
type |
Type |
No description. |
options |
GraphqlTypeOptions |
No description. |
- Type: Type
- Type: GraphqlTypeOptions
Name | Description |
---|---|
argsToString |
Generate the arguments for this field. |
directivesToString |
Generate the directives for this field. |
toString |
Generate the string for this attribute. |
public argsToString(): string
Generate the arguments for this field.
public directivesToString(_modes?: AuthorizationType[]): string
Generate the directives for this field.
- Type: aws-cdk-lib.aws_appsync.AuthorizationType[]
public toString(): string
Generate the string for this attribute.
Name | Description |
---|---|
awsDate |
AWSDate scalar type represents a valid extended ISO 8601 Date string. |
awsDateTime |
AWSDateTime scalar type represents a valid extended ISO 8601 DateTime string. |
awsEmail |
AWSEmail scalar type represents an email address string (i.e.[email protected] ). |
awsIpAddress |
AWSIPAddress scalar type respresents a valid IPv4 of IPv6 address string. |
awsJson |
AWSJson scalar type represents a JSON string. |
awsPhone |
AWSPhone scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated. |
awsTime |
AWSTime scalar type represents a valid extended ISO 8601 Time string. |
awsTimestamp |
AWSTimestamp scalar type represents the number of seconds since 1970-01-01T00:00Z . |
awsUrl |
AWSURL scalar type represetns a valid URL string. |
boolean |
Boolean scalar type is a boolean value: true or false. |
float |
Float scalar type is a signed double-precision fractional value. |
id |
ID scalar type is a unique identifier. ID type is serialized similar to String . |
int |
Int scalar type is a signed non-fractional numerical value. |
intermediate |
an intermediate type to be added as an attribute (i.e. an interface or an object type). |
string |
String scalar type is a free-form human-readable text. |
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsDate(options?: BaseTypeOptions)
AWSDate
scalar type represents a valid extended ISO 8601 Date
string.
In other words, accepts date strings in the form of YYYY-MM-DD
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsDateTime(options?: BaseTypeOptions)
AWSDateTime
scalar type represents a valid extended ISO 8601 DateTime
string.
In other words, accepts date strings in the form of YYYY-MM-DDThh:mm:ss.sssZ
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsEmail(options?: BaseTypeOptions)
AWSEmail
scalar type represents an email address string (i.e.[email protected]
).
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsIpAddress(options?: BaseTypeOptions)
AWSIPAddress
scalar type respresents a valid IPv4
of IPv6
address string.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsJson(options?: BaseTypeOptions)
AWSJson
scalar type represents a JSON string.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsPhone(options?: BaseTypeOptions)
AWSPhone
scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated.
The number can specify a country code at the beginning, but is not required for US phone numbers.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsTime(options?: BaseTypeOptions)
AWSTime
scalar type represents a valid extended ISO 8601 Time
string.
In other words, accepts date strings in the form of hh:mm:ss.sss
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsTimestamp(options?: BaseTypeOptions)
AWSTimestamp
scalar type represents the number of seconds since 1970-01-01T00:00Z
.
Timestamps are serialized and deserialized as numbers.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsUrl(options?: BaseTypeOptions)
AWSURL
scalar type represetns a valid URL string.
URLs wihtout schemes or contain double slashes are considered invalid.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.boolean(options?: BaseTypeOptions)
Boolean
scalar type is a boolean value: true or false.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.float(options?: BaseTypeOptions)
Float
scalar type is a signed double-precision fractional value.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.id(options?: BaseTypeOptions)
ID
scalar type is a unique identifier. ID
type is serialized similar to String
.
Often used as a key for a cache and not intended to be human-readable.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.int(options?: BaseTypeOptions)
Int
scalar type is a signed non-fractional numerical value.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.intermediate(options?: GraphqlTypeOptions)
an intermediate type to be added as an attribute (i.e. an interface or an object type).
- Type: GraphqlTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList - intermediateType.
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.string(options?: BaseTypeOptions)
String
scalar type is a free-form human-readable text.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
Name | Type | Description |
---|---|---|
isList |
boolean |
property determining if this attribute is a list i.e. if true, attribute would be [Type] . |
isRequired |
boolean |
property determining if this attribute is non-nullable i.e. if true, attribute would be Type! and this attribute must always have a value. |
isRequiredList |
boolean |
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! and this attribute's list must always have a value. |
type |
Type |
the type of attribute. |
intermediateType |
IIntermediateType |
the intermediate type linked to this attribute (i.e. an interface or an object). |
public readonly isList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a list i.e. if true, attribute would be [Type]
.
public readonly isRequired: boolean;
- Type: boolean
- Default: false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
and this attribute must always have a value.
public readonly isRequiredList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]!
and this attribute's list must always have a value.
public readonly type: Type;
- Type: Type
the type of attribute.
public readonly intermediateType: IIntermediateType;
- Type: IIntermediateType
- Default: no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
- Implements: IIntermediateType
Input Types are abstract types that define complex objects.
They are used in arguments to represent
import { InputType } from 'awscdk-appsync-utils'
new InputType(name: string, props: IntermediateTypeOptions)
Name | Type | Description |
---|---|---|
name |
string |
No description. |
props |
IntermediateTypeOptions |
No description. |
- Type: string
- Type: IntermediateTypeOptions
Name | Description |
---|---|
addField |
Add a field to this Input Type. |
attribute |
Create a GraphQL Type representing this Input Type. |
toString |
Generate the string of this input type. |
public addField(options: AddFieldOptions): void
Add a field to this Input Type.
Input Types must have both fieldName and field options.
- Type: AddFieldOptions
the options to add a field.
public attribute(options?: BaseTypeOptions): GraphqlType
Create a GraphQL Type representing this Input Type.
- Type: BaseTypeOptions
the options to configure this attribute.
public toString(): string
Generate the string of this input type.
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
name |
string |
the name of this type. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly name: string;
- Type: string
the name of this type.
- Implements: IIntermediateType
Interface Types are abstract types that includes a certain set of fields that other types must include if they implement the interface.
import { InterfaceType } from 'awscdk-appsync-utils'
new InterfaceType(name: string, props: IntermediateTypeOptions)
Name | Type | Description |
---|---|---|
name |
string |
No description. |
props |
IntermediateTypeOptions |
No description. |
- Type: string
- Type: IntermediateTypeOptions
Name | Description |
---|---|
addField |
Add a field to this Interface Type. |
attribute |
Create a GraphQL Type representing this Intermediate Type. |
toString |
Generate the string of this object type. |
public addField(options: AddFieldOptions): void
Add a field to this Interface Type.
Interface Types must have both fieldName and field options.
- Type: AddFieldOptions
the options to add a field.
public attribute(options?: BaseTypeOptions): GraphqlType
Create a GraphQL Type representing this Intermediate Type.
- Type: BaseTypeOptions
the options to configure this attribute.
public toString(): string
Generate the string of this object type.
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
name |
string |
the name of this type. |
directives |
Directive[] |
the directives for this object type. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly name: string;
- Type: string
the name of this type.
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this object type.
- Implements: IIntermediateType
Object Types are types declared by you.
import { ObjectType } from 'awscdk-appsync-utils'
new ObjectType(name: string, props: ObjectTypeOptions)
Name | Type | Description |
---|---|---|
name |
string |
No description. |
props |
ObjectTypeOptions |
No description. |
- Type: string
- Type: ObjectTypeOptions
Name | Description |
---|---|
addField |
Add a field to this Object Type. |
attribute |
Create a GraphQL Type representing this Intermediate Type. |
toString |
Generate the string of this object type. |
public addField(options: AddFieldOptions): void
Add a field to this Object Type.
Object Types must have both fieldName and field options.
- Type: AddFieldOptions
the options to add a field.
public attribute(options?: BaseTypeOptions): GraphqlType
Create a GraphQL Type representing this Intermediate Type.
- Type: BaseTypeOptions
the options to configure this attribute.
public toString(): string
Generate the string of this object type.
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
name |
string |
the name of this type. |
directives |
Directive[] |
the directives for this object type. |
interfaceTypes |
InterfaceType[] |
The Interface Types this Object Type implements. |
resolvers |
aws-cdk-lib.aws_appsync.Resolver[] |
The resolvers linked to this data source. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly name: string;
- Type: string
the name of this type.
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this object type.
public readonly interfaceTypes: InterfaceType[];
- Type: InterfaceType[]
- Default: no interface types
The Interface Types this Object Type implements.
public readonly resolvers: Resolver[];
- Type: aws-cdk-lib.aws_appsync.Resolver[]
The resolvers linked to this data source.
- Implements: IField
Resolvable Fields build upon Graphql Types and provide fields that can resolve into operations on a data source.
import { ResolvableField } from 'awscdk-appsync-utils'
new ResolvableField(options: ResolvableFieldOptions)
Name | Type | Description |
---|---|---|
options |
ResolvableFieldOptions |
No description. |
- Type: ResolvableFieldOptions
Name | Description |
---|---|
argsToString |
Generate the args string of this resolvable field. |
directivesToString |
Generate the directives for this field. |
toString |
Generate the string for this attribute. |
public argsToString(): string
Generate the args string of this resolvable field.
public directivesToString(modes?: AuthorizationType[]): string
Generate the directives for this field.
- Type: aws-cdk-lib.aws_appsync.AuthorizationType[]
public toString(): string
Generate the string for this attribute.
Name | Description |
---|---|
awsDate |
AWSDate scalar type represents a valid extended ISO 8601 Date string. |
awsDateTime |
AWSDateTime scalar type represents a valid extended ISO 8601 DateTime string. |
awsEmail |
AWSEmail scalar type represents an email address string (i.e.[email protected] ). |
awsIpAddress |
AWSIPAddress scalar type respresents a valid IPv4 of IPv6 address string. |
awsJson |
AWSJson scalar type represents a JSON string. |
awsPhone |
AWSPhone scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated. |
awsTime |
AWSTime scalar type represents a valid extended ISO 8601 Time string. |
awsTimestamp |
AWSTimestamp scalar type represents the number of seconds since 1970-01-01T00:00Z . |
awsUrl |
AWSURL scalar type represetns a valid URL string. |
boolean |
Boolean scalar type is a boolean value: true or false. |
float |
Float scalar type is a signed double-precision fractional value. |
id |
ID scalar type is a unique identifier. ID type is serialized similar to String . |
int |
Int scalar type is a signed non-fractional numerical value. |
intermediate |
an intermediate type to be added as an attribute (i.e. an interface or an object type). |
string |
String scalar type is a free-form human-readable text. |
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsDate(options?: BaseTypeOptions)
AWSDate
scalar type represents a valid extended ISO 8601 Date
string.
In other words, accepts date strings in the form of YYYY-MM-DD
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsDateTime(options?: BaseTypeOptions)
AWSDateTime
scalar type represents a valid extended ISO 8601 DateTime
string.
In other words, accepts date strings in the form of YYYY-MM-DDThh:mm:ss.sssZ
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsEmail(options?: BaseTypeOptions)
AWSEmail
scalar type represents an email address string (i.e.[email protected]
).
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsIpAddress(options?: BaseTypeOptions)
AWSIPAddress
scalar type respresents a valid IPv4
of IPv6
address string.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsJson(options?: BaseTypeOptions)
AWSJson
scalar type represents a JSON string.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsPhone(options?: BaseTypeOptions)
AWSPhone
scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated.
The number can specify a country code at the beginning, but is not required for US phone numbers.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsTime(options?: BaseTypeOptions)
AWSTime
scalar type represents a valid extended ISO 8601 Time
string.
In other words, accepts date strings in the form of hh:mm:ss.sss
. It accepts time zone offsets.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsTimestamp(options?: BaseTypeOptions)
AWSTimestamp
scalar type represents the number of seconds since 1970-01-01T00:00Z
.
Timestamps are serialized and deserialized as numbers.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsUrl(options?: BaseTypeOptions)
AWSURL
scalar type represetns a valid URL string.
URLs wihtout schemes or contain double slashes are considered invalid.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.boolean(options?: BaseTypeOptions)
Boolean
scalar type is a boolean value: true or false.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.float(options?: BaseTypeOptions)
Float
scalar type is a signed double-precision fractional value.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.id(options?: BaseTypeOptions)
ID
scalar type is a unique identifier. ID
type is serialized similar to String
.
Often used as a key for a cache and not intended to be human-readable.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.int(options?: BaseTypeOptions)
Int
scalar type is a signed non-fractional numerical value.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.intermediate(options?: GraphqlTypeOptions)
an intermediate type to be added as an attribute (i.e. an interface or an object type).
- Type: GraphqlTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList - intermediateType.
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.string(options?: BaseTypeOptions)
String
scalar type is a free-form human-readable text.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
Name | Type | Description |
---|---|---|
isList |
boolean |
property determining if this attribute is a list i.e. if true, attribute would be [Type] . |
isRequired |
boolean |
property determining if this attribute is non-nullable i.e. if true, attribute would be Type! and this attribute must always have a value. |
isRequiredList |
boolean |
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! and this attribute's list must always have a value. |
type |
Type |
the type of attribute. |
intermediateType |
IIntermediateType |
the intermediate type linked to this attribute (i.e. an interface or an object). |
fieldOptions |
ResolvableFieldOptions |
The options to make this field resolvable. |
public readonly isList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a list i.e. if true, attribute would be [Type]
.
public readonly isRequired: boolean;
- Type: boolean
- Default: false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
and this attribute must always have a value.
public readonly isRequiredList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]!
and this attribute's list must always have a value.
public readonly type: Type;
- Type: Type
the type of attribute.
public readonly intermediateType: IIntermediateType;
- Type: IIntermediateType
- Default: no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
public readonly fieldOptions: ResolvableFieldOptions;
- Type: ResolvableFieldOptions
- Default: not a resolvable field
The options to make this field resolvable.
- Implements: IIntermediateType
Union Types are abstract types that are similar to Interface Types, but they cannot to specify any common fields between types.
Note that fields of a union type need to be object types. In other words, you can't create a union type out of interfaces, other unions, or inputs.
import { UnionType } from 'awscdk-appsync-utils'
new UnionType(name: string, options: UnionTypeOptions)
Name | Type | Description |
---|---|---|
name |
string |
No description. |
options |
UnionTypeOptions |
No description. |
- Type: string
- Type: UnionTypeOptions
Name | Description |
---|---|
addField |
Add a field to this Union Type. |
attribute |
Create a GraphQL Type representing this Union Type. |
toString |
Generate the string of this Union type. |
public addField(options: AddFieldOptions): void
Add a field to this Union Type.
Input Types must have field options and the IField must be an Object Type.
- Type: AddFieldOptions
the options to add a field.
public attribute(options?: BaseTypeOptions): GraphqlType
Create a GraphQL Type representing this Union Type.
- Type: BaseTypeOptions
the options to configure this attribute.
public toString(): string
Generate the string of this Union type.
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
name |
string |
the name of this type. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly name: string;
- Type: string
the name of this type.
- Implemented By: Field, GraphqlType, ResolvableField, IField
A Graphql Field.
Name | Description |
---|---|
argsToString |
Generate the arguments for this field. |
directivesToString |
Generate the directives for this field. |
toString |
Generate the string for this attribute. |
public argsToString(): string
Generate the arguments for this field.
public directivesToString(modes?: AuthorizationType[]): string
Generate the directives for this field.
- Type: aws-cdk-lib.aws_appsync.AuthorizationType[]
the authorization modes of the graphql api.
public toString(): string
Generate the string for this attribute.
Name | Type | Description |
---|---|---|
isList |
boolean |
property determining if this attribute is a list i.e. if true, attribute would be [Type] . |
isRequired |
boolean |
property determining if this attribute is non-nullable i.e. if true, attribute would be Type! and this attribute must always have a value. |
isRequiredList |
boolean |
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]! and this attribute's list must always have a value. |
type |
Type |
the type of attribute. |
fieldOptions |
ResolvableFieldOptions |
The options to make this field resolvable. |
intermediateType |
IIntermediateType |
the intermediate type linked to this attribute (i.e. an interface or an object). |
public readonly isList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a list i.e. if true, attribute would be [Type]
.
public readonly isRequired: boolean;
- Type: boolean
- Default: false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
and this attribute must always have a value.
public readonly isRequiredList: boolean;
- Type: boolean
- Default: false
property determining if this attribute is a non-nullable list i.e. if true, attribute would be [ Type ]!
and this attribute's list must always have a value.
public readonly type: Type;
- Type: Type
the type of attribute.
public readonly fieldOptions: ResolvableFieldOptions;
- Type: ResolvableFieldOptions
- Default: not a resolvable field
The options to make this field resolvable.
public readonly intermediateType: IIntermediateType;
- Type: IIntermediateType
- Default: no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
- Implemented By: EnumType, InputType, InterfaceType, ObjectType, UnionType, IIntermediateType
Intermediate Types are types that includes a certain set of fields that define the entirety of your schema.
Name | Description |
---|---|
addField |
Add a field to this Intermediate Type. |
attribute |
Create an GraphQL Type representing this Intermediate Type. |
toString |
Generate the string of this object type. |
public addField(options: AddFieldOptions): void
Add a field to this Intermediate Type.
- Type: AddFieldOptions
public attribute(options?: BaseTypeOptions): GraphqlType
Create an GraphQL Type representing this Intermediate Type.
- Type: BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
public toString(): string
Generate the string of this object type.
Name | Type | Description |
---|---|---|
definition |
{[ key: string ]: IField} |
the attributes of this type. |
name |
string |
the name of this type. |
directives |
Directive[] |
the directives for this object type. |
interfaceTypes |
InterfaceType[] |
The Interface Types this Intermediate Type implements. |
intermediateType |
IIntermediateType |
the intermediate type linked to this attribute (i.e. an interface or an object). |
resolvers |
aws-cdk-lib.aws_appsync.Resolver[] |
The resolvers linked to this data source. |
public readonly definition: {[ key: string ]: IField};
- Type: {[ key: string ]: IField}
the attributes of this type.
public readonly name: string;
- Type: string
the name of this type.
public readonly directives: Directive[];
- Type: Directive[]
- Default: no directives
the directives for this object type.
public readonly interfaceTypes: InterfaceType[];
- Type: InterfaceType[]
- Default: no interface types
The Interface Types this Intermediate Type implements.
public readonly intermediateType: IIntermediateType;
- Type: IIntermediateType
- Default: no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
public readonly resolvers: Resolver[];
- Type: aws-cdk-lib.aws_appsync.Resolver[]
The resolvers linked to this data source.
-
Extends: constructs.IConstruct
-
Implemented By: SourceApiAssociationMergeOperationProvider, ISourceApiAssociationMergeOperationProvider
This interface for the provider of the custom resource that will be used to initiate a merge operation during Cloudformation update.
Name | Description |
---|---|
associateSourceApiAssociation |
This function associates a source api association with the provider. |
public associateSourceApiAssociation(sourceApiAssociation: ISourceApiAssociation): void
This function associates a source api association with the provider.
This method can be used for adding permissions to merge a specific source api association to the custom resource provider.
- Type: aws-cdk-lib.aws_appsync.ISourceApiAssociation
The association to associate.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
serviceToken |
string |
Service token which is used for identifying the handler used for the merge operation custom resource. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly serviceToken: string;
- Type: string
Service token which is used for identifying the handler used for the merge operation custom resource.
Enum containing the Types that can be used to define ObjectTypes.
Name | Description |
---|---|
ID |
ID scalar type is a unique identifier. ID type is serialized similar to String . |
STRING |
String scalar type is a free-form human-readable text. |
INT |
Int scalar type is a signed non-fractional numerical value. |
FLOAT |
Float scalar type is a signed double-precision fractional value. |
BOOLEAN |
Boolean scalar type is a boolean value: true or false. |
AWS_DATE |
AWSDate scalar type represents a valid extended ISO 8601 Date string. |
AWS_TIME |
AWSTime scalar type represents a valid extended ISO 8601 Time string. |
AWS_DATE_TIME |
AWSDateTime scalar type represents a valid extended ISO 8601 DateTime string. |
AWS_TIMESTAMP |
AWSTimestamp scalar type represents the number of seconds since 1970-01-01T00:00Z . |
AWS_EMAIL |
AWSEmail scalar type represents an email address string (i.e.[email protected] ). |
AWS_JSON |
AWSJson scalar type represents a JSON string. |
AWS_URL |
AWSURL scalar type represetns a valid URL string. |
AWS_PHONE |
AWSPhone scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated. |
AWS_IP_ADDRESS |
AWSIPAddress scalar type respresents a valid IPv4 of IPv6 address string. |
INTERMEDIATE |
Type used for Intermediate Types (i.e. an interface or an object type). |
ID
scalar type is a unique identifier. ID
type is serialized similar to String
.
Often used as a key for a cache and not intended to be human-readable.
String
scalar type is a free-form human-readable text.
Int
scalar type is a signed non-fractional numerical value.
Float
scalar type is a signed double-precision fractional value.
Boolean
scalar type is a boolean value: true or false.
AWSDate
scalar type represents a valid extended ISO 8601 Date
string.
In other words, accepts date strings in the form of YYYY-MM-DD
. It accepts time zone offsets.
AWSTime
scalar type represents a valid extended ISO 8601 Time
string.
In other words, accepts date strings in the form of hh:mm:ss.sss
. It accepts time zone offsets.
AWSDateTime
scalar type represents a valid extended ISO 8601 DateTime
string.
In other words, accepts date strings in the form of YYYY-MM-DDThh:mm:ss.sssZ
. It accepts time zone offsets.
https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
AWSTimestamp
scalar type represents the number of seconds since 1970-01-01T00:00Z
.
Timestamps are serialized and deserialized as numbers.
AWSEmail
scalar type represents an email address string (i.e.[email protected]
).
AWSJson
scalar type represents a JSON string.
AWSURL
scalar type represetns a valid URL string.
URLs wihtout schemes or contain double slashes are considered invalid.
AWSPhone
scalar type represents a valid phone number. Phone numbers maybe be whitespace delimited or hyphenated.
The number can specify a country code at the beginning, but is not required for US phone numbers.
AWSIPAddress
scalar type respresents a valid IPv4
of IPv6
address string.
Type used for Intermediate Types (i.e. an interface or an object type).