# AWS CDK AppSync Utilities
This package contains various utilities for definining GraphQl Apis via AppSync using the [aws-cdk](https://github.com/aws/aws-cdk).
## Code First Schema Definition
`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.
```ts
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() },
}));
```
### Code-First Example
To showcase the code-first approach. Let's try to model the following schema segment.
```gql
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.
```ts nofixture
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.
```ts fixture=with-objects
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](https://github.com/BryanPan342/starwars-code-first).
## GraphQL Types
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**](https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html): Id, Int, String, AWSDate, etc.
- [**Object Types**](#Object-Types): types that you generate (i.e. `demo` from the example above)
- [**Interface Types**](#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
`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 through `Iam`
- `Directive.apiKey()` sets a type or field's authorization to be validated through a `Api Key`
- `Directive.oidc()` sets a type or field's authorization to be validated through `OpenID Connect`
- `Directive.cognito(...groups: string[])` sets a type or field's authorization to be validated
through `Cognito User Pools`
- `groups` the name of the cognito groups to give access
To learn more about authorization and directives, read these docs [here](https://docs.aws.amazon.com/appsync/latest/devguide/security.html).
### Field and Resolvable Fields
While `GraphqlType` is a base implementation for GraphQL fields, we have abstractions
on top of `GraphqlType` that provide finer grain support.
### Field
`Field` extends `GraphqlType` and will allow you to define arguments. [**Interface Types**](#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:
```gql
type Node {
test(argument: string): String
}
```
The CDK code required would be:
```ts
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 },
});
```
### Resolvable Fields
`ResolvableField` extends `Field` and will allow you to define arguments and its resolvers.
[**Object Types**](#Object-Types) can have fields that resolve and perform operations on
your backend.
You can also create resolvable fields for object types.
```gql
type Info {
node(id: String): String
}
```
The CDK code required would be:
```ts
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:
```gql
type Query {
get(argument: string): Info
}
```
The CDK code required would be:
```ts
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](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-overview.html).
### Intermediate Types
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**](#Interface-Types)
- [**Object Types**](#Object-Types)
- [**Enum Types**](#Enum-Types)
- [**Input Types**](#Input-Types)
- [**Union Types**](#Union-Types)
#### Interface Types
**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***.
```ts
const node = new InterfaceType('Node', {
definition: {
id: GraphqlType.string({ isRequired: true }),
},
});
```
To learn more about **Interface Types**, read the docs [here](https://graphql.org/learn/schema/#interfaces).
#### Object Types
**Object Types** are types that you declare. For example, in the [code-first example](#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:
1. Object Types can be created ***externally***.
```ts
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 definitions
```ts nofixture
import { 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 stack
```ts fixture=with-objects
declare const schema: CodeFirstSchema;
schema.addType(demo);
```
2. Object Types can be created ***externally*** from an Interface Type.
```ts
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](https://graphql.org/learn/schema/#object-types-and-fields).
#### Enum Types
**Enum Types** are a special type of Intermediate Type. They restrict a particular
set of allowed values for other Intermediate Types.
```gql
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:
```ts
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](https://graphql.org/learn/schema/#enumeration-types).
#### Input Types
**Input Types** are special types of Intermediate Types. They give users an
easy way to pass complex objects for top level Mutation and Queries.
```gql
input Review {
stars: Int!
commentary: String
}
```
The above GraphQL Input Type can be expressed in CDK as the following:
```ts
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](https://graphql.org/learn/schema/#input-types).
#### Union Types
**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.
```gql
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:
```ts
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](https://graphql.org/learn/schema/#union-types).
### Query
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.
```ts
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](https://docs.aws.amazon.com/appsync/latest/devguide/graphql-overview.html).
### Mutation
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.
```ts
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](https://docs.aws.amazon.com/appsync/latest/devguide/graphql-overview.html).
### Subscription
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.
```ts
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](https://docs.aws.amazon.com/appsync/latest/devguide/real-time-data.html).
## Contributing
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](CONTRIBUTING.md#security-issue-notifications) for more information.
## License
This project is licensed under the Apache-2.0 License.
# API Reference
## Structs
### AddFieldOptions
The options to add a field to an Intermediate Type.
#### Initializer
```typescript
import { AddFieldOptions } from 'awscdk-appsync-utils'
const addFieldOptions: AddFieldOptions = { ... }
```
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| field
| IField
| The resolvable field to add. |
| fieldName
| string
| The name of the field. |
---
##### `field`Optional
```typescript
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.
---
##### `fieldName`Optional
```typescript
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.
---
### BaseTypeOptions
Base options for GraphQL Types.
#### Initializer
```typescript
import { BaseTypeOptions } from 'awscdk-appsync-utils'
const baseTypeOptions: BaseTypeOptions = { ... }
```
#### Properties
| **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! ]! |
---
##### `isList`Optional
```typescript
public readonly isList: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is a list i.e. if true, attribute would be [Type].
---
##### `isRequired`Optional
```typescript
public readonly isRequired: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
---
##### `isRequiredList`Optional
```typescript
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! ]!
---
### EnumTypeOptions
Properties for configuring an Enum Type.
#### Initializer
```typescript
import { EnumTypeOptions } from 'awscdk-appsync-utils'
const enumTypeOptions: EnumTypeOptions = { ... }
```
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| string[]
| the attributes of this type. |
---
##### `definition`Required
```typescript
public readonly definition: string[];
```
- *Type:* string[]
the attributes of this type.
---
### FieldOptions
Properties for configuring a field.
#### Initializer
```typescript
import { FieldOptions } from 'awscdk-appsync-utils'
const fieldOptions: FieldOptions = { ... }
```
#### Properties
| **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. |
---
##### `returnType`Required
```typescript
public readonly returnType: GraphqlType;
```
- *Type:* GraphqlType
The return type for this field.
---
##### `args`Optional
```typescript
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
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this field.
---
### GraphqlTypeOptions
Options for GraphQL Types.
#### Initializer
```typescript
import { GraphqlTypeOptions } from 'awscdk-appsync-utils'
const graphqlTypeOptions: GraphqlTypeOptions = { ... }
```
#### Properties
| **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. |
---
##### `isList`Optional
```typescript
public readonly isList: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is a list i.e. if true, attribute would be [Type].
---
##### `isRequired`Optional
```typescript
public readonly isRequired: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is non-nullable i.e. if true, attribute would be Type!
---
##### `isRequiredList`Optional
```typescript
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! ]!
---
##### `intermediateType`Optional
```typescript
public readonly intermediateType: IIntermediateType;
```
- *Type:* IIntermediateType
- *Default:* no intermediate type
the intermediate type linked to this attribute.
---
### IntermediateTypeOptions
Properties for configuring an Intermediate Type.
#### Initializer
```typescript
import { IntermediateTypeOptions } from 'awscdk-appsync-utils'
const intermediateTypeOptions: IntermediateTypeOptions = { ... }
```
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| {[ key: string ]: IField}
| the attributes of this type. |
| directives
| Directive[]
| the directives for this object type. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this object type.
---
### ObjectTypeOptions
Properties for configuring an Object Type.
#### Initializer
```typescript
import { ObjectTypeOptions } from 'awscdk-appsync-utils'
const objectTypeOptions: ObjectTypeOptions = { ... }
```
#### Properties
| **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. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this object type.
---
##### `interfaceTypes`Optional
```typescript
public readonly interfaceTypes: InterfaceType[];
```
- *Type:* InterfaceType[]
- *Default:* no interface types
The Interface Types this Object Type implements.
---
### ResolvableFieldOptions
Properties for configuring a resolvable field.
#### Initializer
```typescript
import { ResolvableFieldOptions } from 'awscdk-appsync-utils'
const resolvableFieldOptions: ResolvableFieldOptions = { ... }
```
#### Properties
| **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. |
---
##### `returnType`Required
```typescript
public readonly returnType: GraphqlType;
```
- *Type:* GraphqlType
The return type for this field.
---
##### `args`Optional
```typescript
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
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this field.
---
##### `dataSource`Optional
```typescript
public readonly dataSource: BaseDataSource;
```
- *Type:* aws-cdk-lib.aws_appsync.BaseDataSource
- *Default:* no data source
The data source creating linked to this resolvable field.
---
##### `pipelineConfig`Optional
```typescript
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.
---
##### `requestMappingTemplate`Optional
```typescript
public readonly requestMappingTemplate: MappingTemplate;
```
- *Type:* aws-cdk-lib.aws_appsync.MappingTemplate
- *Default:* No mapping template
The request mapping template for this resolver.
---
##### `responseMappingTemplate`Optional
```typescript
public readonly responseMappingTemplate: MappingTemplate;
```
- *Type:* aws-cdk-lib.aws_appsync.MappingTemplate
- *Default:* No mapping template
The response mapping template for this resolver.
---
### UnionTypeOptions
Properties for configuring an Union Type.
#### Initializer
```typescript
import { UnionTypeOptions } from 'awscdk-appsync-utils'
const unionTypeOptions: UnionTypeOptions = { ... }
```
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| IIntermediateType[]
| the object types for this union type. |
---
##### `definition`Required
```typescript
public readonly definition: IIntermediateType[];
```
- *Type:* IIntermediateType[]
the object types for this union type.
---
## Classes
### CodeFirstSchema
- *Implements:* aws-cdk-lib.aws_appsync.ISchema
#### Initializers
```typescript
import { CodeFirstSchema } from 'awscdk-appsync-utils'
new CodeFirstSchema()
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
---
#### Methods
| **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. |
---
##### `addMutation`
```typescript
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
}
###### `fieldName`Required
- *Type:* string
the name of the Mutation.
---
###### `field`Required
- *Type:* ResolvableField
the resolvable field to for this Mutation.
---
##### `addQuery`
```typescript
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
}
###### `fieldName`Required
- *Type:* string
the name of the query.
---
###### `field`Required
- *Type:* ResolvableField
the resolvable field to for this query.
---
##### `addSubscription`
```typescript
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
}
###### `fieldName`Required
- *Type:* string
the name of the Subscription.
---
###### `field`Required
- *Type:* Field
the resolvable field to for this Subscription.
---
##### `addToSchema`
```typescript
public addToSchema(addition: string, delimiter?: string): void
```
Escape hatch to add to Schema as desired.
Will always result
in a newline.
###### `addition`Required
- *Type:* string
the addition to add to schema.
---
###### `delimiter`Optional
- *Type:* string
the delimiter between schema and addition.
---
##### `addType`
```typescript
public addType(type: IIntermediateType): IIntermediateType
```
Add type to the schema.
###### `type`Required
- *Type:* IIntermediateType
the intermediate type to add to the schema.
---
##### `bind`
```typescript
public bind(api: IGraphqlApi, _options?: SchemaBindOptions): ISchemaConfig
```
Called when the GraphQL Api is initialized to allow this object to bind to the stack.
###### `api`Required
- *Type:* aws-cdk-lib.aws_appsync.IGraphqlApi
The binding GraphQL Api.
---
###### `_options`Optional
- *Type:* aws-cdk-lib.aws_appsync.SchemaBindOptions
---
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| string
| The definition for this schema. |
---
##### `definition`Required
```typescript
public readonly definition: string;
```
- *Type:* string
The definition for this schema.
---
### Directive
Directives for types.
i.e. @aws_iam or @aws_subscribe
#### Methods
| **Name** | **Description** |
| --- | --- |
| toString
| Generate the directive statement. |
---
##### `toString`
```typescript
public toString(): string
```
Generate the directive statement.
#### Static Functions
| **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. |
---
##### `apiKey`
```typescript
import { Directive } from 'awscdk-appsync-utils'
Directive.apiKey()
```
Add the @aws_api_key directive.
##### `cognito`
```typescript
import { Directive } from 'awscdk-appsync-utils'
Directive.cognito(groups: string)
```
Add the @aws_auth or @aws_cognito_user_pools directive.
###### `groups`Required
- *Type:* string
the groups to allow access to.
---
##### `custom`
```typescript
import { Directive } from 'awscdk-appsync-utils'
Directive.custom(statement: string)
```
Add a custom directive.
###### `statement`Required
- *Type:* string
the directive statement to append.
---
##### `iam`
```typescript
import { Directive } from 'awscdk-appsync-utils'
Directive.iam()
```
Add the @aws_iam directive.
##### `oidc`
```typescript
import { Directive } from 'awscdk-appsync-utils'
Directive.oidc()
```
Add the @aws_oidc directive.
##### `subscribe`
```typescript
import { Directive } from 'awscdk-appsync-utils'
Directive.subscribe(mutations: string)
```
Add the @aws_subscribe directive.
Only use for top level Subscription type.
###### `mutations`Required
- *Type:* string
the mutation fields to link to.
---
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| mode
| aws-cdk-lib.aws_appsync.AuthorizationType
| The authorization type of this directive. |
| mutationFields
| string[]
| Mutation fields for a subscription directive. |
---
##### `mode`Optional
```typescript
public readonly mode: AuthorizationType;
```
- *Type:* aws-cdk-lib.aws_appsync.AuthorizationType
- *Default:* not an authorization directive
The authorization type of this directive.
---
##### `mutationFields`Optional
```typescript
public readonly mutationFields: string[];
```
- *Type:* string[]
- *Default:* not a subscription directive
Mutation fields for a subscription directive.
---
### EnumType
- *Implements:* IIntermediateType
Enum Types are abstract types that includes a set of fields that represent the strings this type can create.
#### Initializers
```typescript
import { EnumType } from 'awscdk-appsync-utils'
new EnumType(name: string, options: EnumTypeOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| name
| string
| *No description.* |
| options
| EnumTypeOptions
| *No description.* |
---
##### `name`Required
- *Type:* string
---
##### `options`Required
- *Type:* EnumTypeOptions
---
#### Methods
| **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. |
---
##### `addField`
```typescript
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.
###### `options`Required
- *Type:* AddFieldOptions
the options to add a field.
---
##### `attribute`
```typescript
public attribute(options?: BaseTypeOptions): GraphqlType
```
Create an GraphQL Type representing this Enum Type.
###### `options`Optional
- *Type:* BaseTypeOptions
---
##### `toString`
```typescript
public toString(): string
```
Generate the string of this enum type.
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| {[ key: string ]: IField}
| the attributes of this type. |
| name
| string
| the name of this type. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `name`Required
```typescript
public readonly name: string;
```
- *Type:* string
the name of this type.
---
### Field
- *Implements:* IField
Fields build upon Graphql Types and provide typing and arguments.
#### Initializers
```typescript
import { Field } from 'awscdk-appsync-utils'
new Field(options: FieldOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| options
| FieldOptions
| *No description.* |
---
##### `options`Required
- *Type:* FieldOptions
---
#### Methods
| **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. |
---
##### `argsToString`
```typescript
public argsToString(): string
```
Generate the args string of this resolvable field.
##### `directivesToString`
```typescript
public directivesToString(modes?: AuthorizationType[]): string
```
Generate the directives for this field.
###### `modes`Optional
- *Type:* aws-cdk-lib.aws_appsync.AuthorizationType[]
---
##### `toString`
```typescript
public toString(): string
```
Generate the string for this attribute.
#### Static Functions
| **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.`username@example.com`). |
| 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. |
---
##### `awsDate`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsDateTime`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsEmail`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.awsEmail(options?: BaseTypeOptions)
```
`AWSEmail` scalar type represents an email address string (i.e.`username@example.com`).
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsIpAddress`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.awsIpAddress(options?: BaseTypeOptions)
```
`AWSIPAddress` scalar type respresents a valid `IPv4` of `IPv6` address string.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsJson`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.awsJson(options?: BaseTypeOptions)
```
`AWSJson` scalar type represents a JSON string.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsPhone`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsTime`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsTimestamp`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsUrl`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `boolean`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.boolean(options?: BaseTypeOptions)
```
`Boolean` scalar type is a boolean value: true or false.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `float`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.float(options?: BaseTypeOptions)
```
`Float` scalar type is a signed double-precision fractional value.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `id`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `int`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.int(options?: BaseTypeOptions)
```
`Int` scalar type is a signed non-fractional numerical value.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `intermediate`
```typescript
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).
###### `options`Optional
- *Type:* GraphqlTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList - intermediateType.
---
##### `string`
```typescript
import { Field } from 'awscdk-appsync-utils'
Field.string(options?: BaseTypeOptions)
```
`String` scalar type is a free-form human-readable text.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
#### Properties
| **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. |
---
##### `isList`Required
```typescript
public readonly isList: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is a list i.e. if true, attribute would be `[Type]`.
---
##### `isRequired`Required
```typescript
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.
---
##### `isRequiredList`Required
```typescript
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.
---
##### `type`Required
```typescript
public readonly type: Type;
```
- *Type:* Type
the type of attribute.
---
##### `intermediateType`Optional
```typescript
public readonly intermediateType: IIntermediateType;
```
- *Type:* IIntermediateType
- *Default:* no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
---
##### `fieldOptions`Optional
```typescript
public readonly fieldOptions: ResolvableFieldOptions;
```
- *Type:* ResolvableFieldOptions
- *Default:* no arguments
The options for this field.
---
### GraphqlType
- *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.
#### Initializers
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
new GraphqlType(type: Type, options?: GraphqlTypeOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| type
| Type
| *No description.* |
| options
| GraphqlTypeOptions
| *No description.* |
---
##### `type`Required
- *Type:* Type
---
##### `options`Optional
- *Type:* GraphqlTypeOptions
---
#### Methods
| **Name** | **Description** |
| --- | --- |
| argsToString
| Generate the arguments for this field. |
| directivesToString
| Generate the directives for this field. |
| toString
| Generate the string for this attribute. |
---
##### `argsToString`
```typescript
public argsToString(): string
```
Generate the arguments for this field.
##### `directivesToString`
```typescript
public directivesToString(_modes?: AuthorizationType[]): string
```
Generate the directives for this field.
###### `_modes`Optional
- *Type:* aws-cdk-lib.aws_appsync.AuthorizationType[]
---
##### `toString`
```typescript
public toString(): string
```
Generate the string for this attribute.
#### Static Functions
| **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.`username@example.com`). |
| 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. |
---
##### `awsDate`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsDateTime`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsEmail`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsEmail(options?: BaseTypeOptions)
```
`AWSEmail` scalar type represents an email address string (i.e.`username@example.com`).
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsIpAddress`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsIpAddress(options?: BaseTypeOptions)
```
`AWSIPAddress` scalar type respresents a valid `IPv4` of `IPv6` address string.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsJson`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.awsJson(options?: BaseTypeOptions)
```
`AWSJson` scalar type represents a JSON string.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsPhone`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsTime`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsTimestamp`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsUrl`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `boolean`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.boolean(options?: BaseTypeOptions)
```
`Boolean` scalar type is a boolean value: true or false.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `float`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.float(options?: BaseTypeOptions)
```
`Float` scalar type is a signed double-precision fractional value.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `id`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `int`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.int(options?: BaseTypeOptions)
```
`Int` scalar type is a signed non-fractional numerical value.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `intermediate`
```typescript
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).
###### `options`Optional
- *Type:* GraphqlTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList - intermediateType.
---
##### `string`
```typescript
import { GraphqlType } from 'awscdk-appsync-utils'
GraphqlType.string(options?: BaseTypeOptions)
```
`String` scalar type is a free-form human-readable text.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
#### Properties
| **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). |
---
##### `isList`Required
```typescript
public readonly isList: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is a list i.e. if true, attribute would be `[Type]`.
---
##### `isRequired`Required
```typescript
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.
---
##### `isRequiredList`Required
```typescript
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.
---
##### `type`Required
```typescript
public readonly type: Type;
```
- *Type:* Type
the type of attribute.
---
##### `intermediateType`Optional
```typescript
public readonly intermediateType: IIntermediateType;
```
- *Type:* IIntermediateType
- *Default:* no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
---
### InputType
- *Implements:* IIntermediateType
Input Types are abstract types that define complex objects.
They are used in arguments to represent
#### Initializers
```typescript
import { InputType } from 'awscdk-appsync-utils'
new InputType(name: string, props: IntermediateTypeOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| name
| string
| *No description.* |
| props
| IntermediateTypeOptions
| *No description.* |
---
##### `name`Required
- *Type:* string
---
##### `props`Required
- *Type:* IntermediateTypeOptions
---
#### Methods
| **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. |
---
##### `addField`
```typescript
public addField(options: AddFieldOptions): void
```
Add a field to this Input Type.
Input Types must have both fieldName and field options.
###### `options`Required
- *Type:* AddFieldOptions
the options to add a field.
---
##### `attribute`
```typescript
public attribute(options?: BaseTypeOptions): GraphqlType
```
Create a GraphQL Type representing this Input Type.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute.
---
##### `toString`
```typescript
public toString(): string
```
Generate the string of this input type.
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| {[ key: string ]: IField}
| the attributes of this type. |
| name
| string
| the name of this type. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `name`Required
```typescript
public readonly name: string;
```
- *Type:* string
the name of this type.
---
### InterfaceType
- *Implements:* IIntermediateType
Interface Types are abstract types that includes a certain set of fields that other types must include if they implement the interface.
#### Initializers
```typescript
import { InterfaceType } from 'awscdk-appsync-utils'
new InterfaceType(name: string, props: IntermediateTypeOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| name
| string
| *No description.* |
| props
| IntermediateTypeOptions
| *No description.* |
---
##### `name`Required
- *Type:* string
---
##### `props`Required
- *Type:* IntermediateTypeOptions
---
#### Methods
| **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. |
---
##### `addField`
```typescript
public addField(options: AddFieldOptions): void
```
Add a field to this Interface Type.
Interface Types must have both fieldName and field options.
###### `options`Required
- *Type:* AddFieldOptions
the options to add a field.
---
##### `attribute`
```typescript
public attribute(options?: BaseTypeOptions): GraphqlType
```
Create a GraphQL Type representing this Intermediate Type.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute.
---
##### `toString`
```typescript
public toString(): string
```
Generate the string of this object type.
#### Properties
| **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. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `name`Required
```typescript
public readonly name: string;
```
- *Type:* string
the name of this type.
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this object type.
---
### ObjectType
- *Implements:* IIntermediateType
Object Types are types declared by you.
#### Initializers
```typescript
import { ObjectType } from 'awscdk-appsync-utils'
new ObjectType(name: string, props: ObjectTypeOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| name
| string
| *No description.* |
| props
| ObjectTypeOptions
| *No description.* |
---
##### `name`Required
- *Type:* string
---
##### `props`Required
- *Type:* ObjectTypeOptions
---
#### Methods
| **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. |
---
##### `addField`
```typescript
public addField(options: AddFieldOptions): void
```
Add a field to this Object Type.
Object Types must have both fieldName and field options.
###### `options`Required
- *Type:* AddFieldOptions
the options to add a field.
---
##### `attribute`
```typescript
public attribute(options?: BaseTypeOptions): GraphqlType
```
Create a GraphQL Type representing this Intermediate Type.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute.
---
##### `toString`
```typescript
public toString(): string
```
Generate the string of this object type.
#### Properties
| **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. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `name`Required
```typescript
public readonly name: string;
```
- *Type:* string
the name of this type.
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this object type.
---
##### `interfaceTypes`Optional
```typescript
public readonly interfaceTypes: InterfaceType[];
```
- *Type:* InterfaceType[]
- *Default:* no interface types
The Interface Types this Object Type implements.
---
##### `resolvers`Optional
```typescript
public readonly resolvers: Resolver[];
```
- *Type:* aws-cdk-lib.aws_appsync.Resolver[]
The resolvers linked to this data source.
---
### ResolvableField
- *Implements:* IField
Resolvable Fields build upon Graphql Types and provide fields that can resolve into operations on a data source.
#### Initializers
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
new ResolvableField(options: ResolvableFieldOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| options
| ResolvableFieldOptions
| *No description.* |
---
##### `options`Required
- *Type:* ResolvableFieldOptions
---
#### Methods
| **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. |
---
##### `argsToString`
```typescript
public argsToString(): string
```
Generate the args string of this resolvable field.
##### `directivesToString`
```typescript
public directivesToString(modes?: AuthorizationType[]): string
```
Generate the directives for this field.
###### `modes`Optional
- *Type:* aws-cdk-lib.aws_appsync.AuthorizationType[]
---
##### `toString`
```typescript
public toString(): string
```
Generate the string for this attribute.
#### Static Functions
| **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.`username@example.com`). |
| 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. |
---
##### `awsDate`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsDateTime`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsEmail`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsEmail(options?: BaseTypeOptions)
```
`AWSEmail` scalar type represents an email address string (i.e.`username@example.com`).
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsIpAddress`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsIpAddress(options?: BaseTypeOptions)
```
`AWSIPAddress` scalar type respresents a valid `IPv4` of `IPv6` address string.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsJson`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.awsJson(options?: BaseTypeOptions)
```
`AWSJson` scalar type represents a JSON string.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsPhone`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsTime`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsTimestamp`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `awsUrl`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `boolean`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.boolean(options?: BaseTypeOptions)
```
`Boolean` scalar type is a boolean value: true or false.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `float`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.float(options?: BaseTypeOptions)
```
`Float` scalar type is a signed double-precision fractional value.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `id`
```typescript
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.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `int`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.int(options?: BaseTypeOptions)
```
`Int` scalar type is a signed non-fractional numerical value.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `intermediate`
```typescript
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).
###### `options`Optional
- *Type:* GraphqlTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList - intermediateType.
---
##### `string`
```typescript
import { ResolvableField } from 'awscdk-appsync-utils'
ResolvableField.string(options?: BaseTypeOptions)
```
`String` scalar type is a free-form human-readable text.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
#### Properties
| **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. |
---
##### `isList`Required
```typescript
public readonly isList: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is a list i.e. if true, attribute would be `[Type]`.
---
##### `isRequired`Required
```typescript
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.
---
##### `isRequiredList`Required
```typescript
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.
---
##### `type`Required
```typescript
public readonly type: Type;
```
- *Type:* Type
the type of attribute.
---
##### `intermediateType`Optional
```typescript
public readonly intermediateType: IIntermediateType;
```
- *Type:* IIntermediateType
- *Default:* no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
---
##### `fieldOptions`Optional
```typescript
public readonly fieldOptions: ResolvableFieldOptions;
```
- *Type:* ResolvableFieldOptions
- *Default:* not a resolvable field
The options to make this field resolvable.
---
### UnionType
- *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.
#### Initializers
```typescript
import { UnionType } from 'awscdk-appsync-utils'
new UnionType(name: string, options: UnionTypeOptions)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| name
| string
| *No description.* |
| options
| UnionTypeOptions
| *No description.* |
---
##### `name`Required
- *Type:* string
---
##### `options`Required
- *Type:* UnionTypeOptions
---
#### Methods
| **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. |
---
##### `addField`
```typescript
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.
###### `options`Required
- *Type:* AddFieldOptions
the options to add a field.
---
##### `attribute`
```typescript
public attribute(options?: BaseTypeOptions): GraphqlType
```
Create a GraphQL Type representing this Union Type.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute.
---
##### `toString`
```typescript
public toString(): string
```
Generate the string of this Union type.
#### Properties
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| definition
| {[ key: string ]: IField}
| the attributes of this type. |
| name
| string
| the name of this type. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `name`Required
```typescript
public readonly name: string;
```
- *Type:* string
the name of this type.
---
## Protocols
### IField
- *Implemented By:* Field, GraphqlType, ResolvableField, IField
A Graphql Field.
#### Methods
| **Name** | **Description** |
| --- | --- |
| argsToString
| Generate the arguments for this field. |
| directivesToString
| Generate the directives for this field. |
| toString
| Generate the string for this attribute. |
---
##### `argsToString`
```typescript
public argsToString(): string
```
Generate the arguments for this field.
##### `directivesToString`
```typescript
public directivesToString(modes?: AuthorizationType[]): string
```
Generate the directives for this field.
###### `modes`Optional
- *Type:* aws-cdk-lib.aws_appsync.AuthorizationType[]
the authorization modes of the graphql api.
---
##### `toString`
```typescript
public toString(): string
```
Generate the string for this attribute.
#### Properties
| **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). |
---
##### `isList`Required
```typescript
public readonly isList: boolean;
```
- *Type:* boolean
- *Default:* false
property determining if this attribute is a list i.e. if true, attribute would be `[Type]`.
---
##### `isRequired`Required
```typescript
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.
---
##### `isRequiredList`Required
```typescript
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.
---
##### `type`Required
```typescript
public readonly type: Type;
```
- *Type:* Type
the type of attribute.
---
##### `fieldOptions`Optional
```typescript
public readonly fieldOptions: ResolvableFieldOptions;
```
- *Type:* ResolvableFieldOptions
- *Default:* not a resolvable field
The options to make this field resolvable.
---
##### `intermediateType`Optional
```typescript
public readonly intermediateType: IIntermediateType;
```
- *Type:* IIntermediateType
- *Default:* no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
---
### IIntermediateType
- *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.
#### Methods
| **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. |
---
##### `addField`
```typescript
public addField(options: AddFieldOptions): void
```
Add a field to this Intermediate Type.
###### `options`Required
- *Type:* AddFieldOptions
---
##### `attribute`
```typescript
public attribute(options?: BaseTypeOptions): GraphqlType
```
Create an GraphQL Type representing this Intermediate Type.
###### `options`Optional
- *Type:* BaseTypeOptions
the options to configure this attribute - isList - isRequired - isRequiredList.
---
##### `toString`
```typescript
public toString(): string
```
Generate the string of this object type.
#### Properties
| **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. |
---
##### `definition`Required
```typescript
public readonly definition: {[ key: string ]: IField};
```
- *Type:* {[ key: string ]: IField}
the attributes of this type.
---
##### `name`Required
```typescript
public readonly name: string;
```
- *Type:* string
the name of this type.
---
##### `directives`Optional
```typescript
public readonly directives: Directive[];
```
- *Type:* Directive[]
- *Default:* no directives
the directives for this object type.
---
##### `interfaceTypes`Optional
```typescript
public readonly interfaceTypes: InterfaceType[];
```
- *Type:* InterfaceType[]
- *Default:* no interface types
The Interface Types this Intermediate Type implements.
---
##### `intermediateType`Optional
```typescript
public readonly intermediateType: IIntermediateType;
```
- *Type:* IIntermediateType
- *Default:* no intermediate type
the intermediate type linked to this attribute (i.e. an interface or an object).
---
##### `resolvers`Optional
```typescript
public readonly resolvers: Resolver[];
```
- *Type:* aws-cdk-lib.aws_appsync.Resolver[]
The resolvers linked to this data source.
---
## Enums
### Type
Enum containing the Types that can be used to define ObjectTypes.
#### Members
| **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.`username@example.com`). |
| 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`
`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`
`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.
In other words, accepts date strings in the form of `YYYY-MM-DD`. It accepts time zone offsets.
> [https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates](https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates)
---
##### `AWS_TIME`
`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.
> [https://en.wikipedia.org/wiki/ISO_8601#Times](https://en.wikipedia.org/wiki/ISO_8601#Times)
---
##### `AWS_DATE_TIME`
`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](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations)
---
##### `AWS_TIMESTAMP`
`AWSTimestamp` scalar type represents the number of seconds since `1970-01-01T00:00Z`.
Timestamps are serialized and deserialized as numbers.
---
##### `AWS_EMAIL`
`AWSEmail` scalar type represents an email address string (i.e.`username@example.com`).
---
##### `AWS_JSON`
`AWSJson` scalar type represents a JSON string.
---
##### `AWS_URL`
`AWSURL` scalar type represetns a valid URL string.
URLs wihtout schemes or contain double slashes are considered invalid.
---
##### `AWS_PHONE`
`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.
---
##### `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).
---