class ObjectType
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.AppSync.ObjectType |
Java | software.amazon.awscdk.services.appsync.ObjectType |
Python | aws_cdk.aws_appsync.ObjectType |
TypeScript (source) | @aws-cdk/aws-appsync » ObjectType |
Implements
IIntermediate
Extends
Interface
Object Types are types declared by you.
Example
declare const api: appsync.GraphqlApi;
declare const dummyRequest: appsync.MappingTemplate;
declare const dummyResponse: appsync.MappingTemplate;
const info = new appsync.ObjectType('Info', {
definition: {
node: new appsync.ResolvableField({
returnType: appsync.GraphqlType.string(),
args: {
id: appsync.GraphqlType.string(),
},
dataSource: api.addNoneDataSource('none'),
requestMappingTemplate: dummyRequest,
responseMappingTemplate: dummyResponse,
}),
},
});
Initializer
new ObjectType(name: string, props: ObjectTypeOptions)
Parameters
- name
string
- props
Object
Type Options
Properties
Name | Type | Description |
---|---|---|
definition | { [string]: IField } | the attributes of this type. |
name | string | the name of this type. |
directives? | Directive [] | the directives for this object type. |
interface | Interface [] | The Interface Types this Object Type implements. |
resolvers? | Resolver [] | The resolvers linked to this data source. |
definition
Type:
{ [string]:
IField
}
the attributes of this type.
name
Type:
string
the name of this type.
directives?
Type:
Directive
[]
(optional, default: no directives)
the directives for this object type.
interfaceTypes?
Type:
Interface
[]
(optional, default: no interface types)
The Interface Types this Object Type implements.
resolvers?
Type:
Resolver
[]
(optional)
The resolvers linked to this data source.
Methods
Name | Description |
---|---|
add | Add a field to this Object Type. |
attribute(options?) | Create a GraphQL Type representing this Intermediate Type. |
to | Generate the string of this object type. |
protected generate | Generate the resolvers linked to this Object Type. |
addField(options)
public addField(options: AddFieldOptions): void
Parameters
- options
Add
— the options to add a field.Field Options
Add a field to this Object Type.
Object Types must have both fieldName and field options.
attribute(options?)
public attribute(options?: BaseTypeOptions): GraphqlType
Parameters
- options
Base
— the options to configure this attribute.Type Options
Returns
Create a GraphQL Type representing this Intermediate Type.
toString()
public toString(): string
Returns
string
Generate the string of this object type.
protected generateResolver(api, fieldName, options?)
protected generateResolver(api: IGraphqlApi, fieldName: string, options?: ResolvableFieldOptions): Resolver
Parameters
- api
IGraphql
Api - fieldName
string
- options
Resolvable
Field Options
Returns
Generate the resolvers linked to this Object Type.