Version: 0.15.x

SchemaCRUDPlugin

Graphback CRUD operations plugin

Plugins adds additional Queries, Mutations and Subscriptions into the Schema along with required input types and scalars. Plugin can be used automatically define best patterns for CRUD operations on top of GraphQL Schema Plugin checkes all types annotated with model

Used graphql metadata:

  • model: marks type to be processed by CRUD generator
  • crud: controls what types of operations can be generated. For example crud.update: false will disable updates for type

Hierarchy

  • GraphbackPlugin

    SchemaCRUDPlugin

Index

Constructors

Properties

Methods

Constructors

constructor

+ new SchemaCRUDPlugin(pluginConfig?: SchemaCRUDPluginConfig): SchemaCRUDPlugin

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:41

Parameters:

NameType
pluginConfig?SchemaCRUDPluginConfig

Returns: SchemaCRUDPlugin

Properties

Private pluginConfig

pluginConfig: SchemaCRUDPluginConfig

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:41

Methods

Protected addCreateMutationResolver

addCreateMutationResolver(model: ModelDefinition, mutationObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:477

Creates a Create mutation resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel GraphQL object type
mutationObjIFieldResolver‹any, any›Mutation resolver object

Returns: void


Protected addCreateSubscriptionResolver

addCreateSubscriptionResolver(modelType: GraphQLObjectType, subscriptionObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:603

Creates a Create Subscription resolver field

Parameters:

NameTypeDescription
modelTypeGraphQLObjectTypeModel GraphQL object type
subscriptionObjIFieldResolver‹any, any›-

Returns: void


Protected addDeleteMutationResolver

addDeleteMutationResolver(model: ModelDefinition, mutationObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:528

Creates a Delete Mutation resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
mutationObjIFieldResolver‹any, any›Mutation resolver object

Returns: void


Protected addDeleteSubscriptionResolver

addDeleteSubscriptionResolver(modelType: GraphQLObjectType, subscriptionObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:645

Creates a Delete Subscription resolver field

Parameters:

NameTypeDescription
modelTypeGraphQLObjectTypeModel GraphQL object type
subscriptionObjIFieldResolver‹any, any›-

Returns: void


Protected addFindOneQueryResolver

addFindOneQueryResolver(model: ModelDefinition, queryObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:576

Creates a FindOne Query resolver

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
queryObjIFieldResolver‹any, any›-

Returns: void


Protected addFindQueryResolver

addFindQueryResolver(model: ModelDefinition, queryObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:553

Creates a Find Query resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
queryObjIFieldResolver‹any, any›-

Returns: void


Protected addMutationResolvers

addMutationResolvers(model: ModelDefinition, mutationObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:417

Create Mutation resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionThe model definition with CRUD config and GraphQL typr
mutationObjIFieldResolver‹any, any›Mutation resolver object

Returns: void


Protected addOneToManyResolver

addOneToManyResolver(relationship: FieldRelationshipMetadata, resolverObj: IResolvers, modelNameToModelDefinition: any): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:667

Creates a OneToMany Relationship resolver field

Parameters:

NameTypeDescription
relationshipFieldRelationshipMetadata-
resolverObjIResolversResolvers object
modelNameToModelDefinitionanymodel type name to its definition for quick search

Returns: void


Protected addOneToOneResolver

addOneToOneResolver(relationship: FieldRelationshipMetadata, resolverObj: IResolvers, modelNameToModelDefinition: any): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:700

Creates a OneToOne/ManyToOne Relationship resolver field

Parameters:

NameTypeDescription
relationshipFieldRelationshipMetadata-
resolverObjIResolversResolvers object
modelNameToModelDefinitionanymodel type name to its definition for quick search

Returns: void


Protected addQueryResolvers

addQueryResolvers(model: ModelDefinition, queryObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:402

Create Query resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionThe model definition with CRUD config and GraphQL typr
queryObjIFieldResolver‹any, any›Query resolver object

Returns: void


Protected addRelationshipResolvers

addRelationshipResolvers(model: ModelDefinition, resolversObj: IResolvers, modelNameToModelDefinition: any): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:456

Create relationship resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionModel definition with relationship metadata
resolversObjIResolversResolvers object
modelNameToModelDefinitionanymodel type name to its definition for quick search

Returns: void


Protected addSubscriptionResolvers

addSubscriptionResolvers(model: ModelDefinition, subscriptionObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:435

Create Subscription resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionThe model definition with CRUD config and GraphQL typr
subscriptionObjIFieldResolver‹any, any›Subscription resolver object

Returns: void


Protected addUpdateMutationResolver

addUpdateMutationResolver(model: ModelDefinition, mutationObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:503

Creates an Update mutation resolver

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
mutationObjIFieldResolver‹any, any›Mutation resolver object

Returns: void


Protected addUpdateSubscriptionResolver

addUpdateSubscriptionResolver(modelType: GraphQLObjectType, subscriptionObj: IFieldResolver‹any, any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:624

Creates an Update Subscription resolver field

Parameters:

NameTypeDescription
modelTypeGraphQLObjectTypeModel GraphQL object type
subscriptionObjIFieldResolver‹any, any›-

Returns: void


Protected addVersionedMetadataFields

addVersionedMetadataFields(schemaComposer: SchemaComposer‹any›, models: ModelDefinition[]): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:352

Parameters:

NameType
schemaComposerSchemaComposer‹any›
modelsModelDefinition[]

Returns: void


Protected buildSchemaForModels

buildSchemaForModels(schemaComposer: SchemaComposer‹any›, models: ModelDefinition[]): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:145

Parameters:

NameType
schemaComposerSchemaComposer‹any›
modelsModelDefinition[]

Returns: void


Private buildSchemaModelRelationships

buildSchemaModelRelationships(schemaComposer: SchemaComposer‹any›, models: ModelDefinition[]): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:752

Add relationship fields to GraphQL model types

Parameters:

NameTypeDescription
schemaComposerSchemaComposer‹any›-
modelsModelDefinition[]

Returns: void


Protected createMutations

createMutations(model: ModelDefinition, schemaComposer: SchemaComposer‹any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:248

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


Protected createQueries

createQueries(model: ModelDefinition, schemaComposer: SchemaComposer‹any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:310

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


createResolvers

createResolvers(metadata: GraphbackCoreMetadata): IResolvers

Overrides void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:74

Creates CRUD resolvers

Parameters:

NameTypeDescription
metadataGraphbackCoreMetadataCore metatata containing all model information

Returns: IResolvers


createResources

createResources(metadata: GraphbackCoreMetadata): void

Overrides void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:114

Parameters:

NameType
metadataGraphbackCoreMetadata

Returns: void


Protected createSchema

createSchema(queryTypes: any, mutationTypes: any, subscriptionTypes: any): GraphQLSchema‹›

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:219

Parameters:

NameType
queryTypesany
mutationTypesany
subscriptionTypesany

Returns: GraphQLSchema‹›


Private createSchemaCRUDTypes

createSchemaCRUDTypes(schemaComposer: SchemaComposer‹any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:721

Parameters:

NameType
schemaComposerSchemaComposer‹any›

Returns: void


Protected createSubscriptions

createSubscriptions(model: ModelDefinition, schemaComposer: SchemaComposer‹any›): void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:162

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


getPluginName

getPluginName(): string

Overrides void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:141

Returns: string


Protected logError

logError(message: string): void

Inherited from SchemaCRUDPlugin.logError

Defined in graphback-core/types/plugin/GraphbackPlugin.d.ts:37

Parameters:

NameType
messagestring

Returns: void


Protected logWarning

logWarning(message: string): void

Inherited from SchemaCRUDPlugin.logWarning

Defined in graphback-core/types/plugin/GraphbackPlugin.d.ts:36

Parameters:

NameType
messagestring

Returns: void


transformSchema

transformSchema(metadata: GraphbackCoreMetadata): GraphQLSchema

Overrides void

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:50

Parameters:

NameType
metadataGraphbackCoreMetadata

Returns: GraphQLSchema


Protected transformSchemaToString

transformSchemaToString(schema: GraphQLSchema, fileExtension: string): string

Defined in graphback-codegen-schema/src/SchemaCRUDPlugin.ts:380

Print schema as a string and format in one of the available languages

Parameters:

NameTypeDescription
schemaGraphQLSchema-
fileExtensionstring

Returns: string