Version: 0.16.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:42

Parameters:

NameType
pluginConfig?SchemaCRUDPluginConfig

Returns: SchemaCRUDPlugin

Properties

Private pluginConfig

pluginConfig: SchemaCRUDPluginConfig

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

Methods

Protected addCreateMutationResolver

addCreateMutationResolver(model: ModelDefinition, mutationObj: IObjectTypeResolver): void

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

Creates a Create mutation resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel GraphQL object type
mutationObjIObjectTypeResolverMutation resolver object

Returns: void


Protected addCreateSubscriptionResolver

addCreateSubscriptionResolver(modelType: GraphQLObjectType, subscriptionObj: IObjectTypeResolver): void

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

Creates a Create Subscription resolver field

Parameters:

NameTypeDescription
modelTypeGraphQLObjectTypeModel GraphQL object type
subscriptionObjIObjectTypeResolver-

Returns: void


Protected addDeleteMutationResolver

addDeleteMutationResolver(model: ModelDefinition, mutationObj: IObjectTypeResolver): void

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

Creates a Delete Mutation resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
mutationObjIObjectTypeResolverMutation resolver object

Returns: void


Protected addDeleteSubscriptionResolver

addDeleteSubscriptionResolver(modelType: GraphQLObjectType, subscriptionObj: IObjectTypeResolver): void

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

Creates a Delete Subscription resolver field

Parameters:

NameTypeDescription
modelTypeGraphQLObjectTypeModel GraphQL object type
subscriptionObjIObjectTypeResolver-

Returns: void


Protected addFindOneQueryResolver

addFindOneQueryResolver(model: ModelDefinition, queryObj: IObjectTypeResolver): void

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

Creates a FindOne Query resolver

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
queryObjIObjectTypeResolver-

Returns: void


Protected addFindQueryResolver

addFindQueryResolver(model: ModelDefinition, queryObj: IObjectTypeResolver): void

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

Creates a Find Query resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
queryObjIObjectTypeResolver-

Returns: void


Protected addMutationResolvers

addMutationResolvers(model: ModelDefinition, mutationObj: IObjectTypeResolver): void

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

Create Mutation resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionThe model definition with CRUD config and GraphQL typr
mutationObjIObjectTypeResolverMutation resolver object

Returns: void


Protected addOneToManyResolver

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

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

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:691

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: IObjectTypeResolver): void

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

Create Query resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionThe model definition with CRUD config and GraphQL typr
queryObjIObjectTypeResolverQuery resolver object

Returns: void


Protected addRelationshipResolvers

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

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

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: IObjectTypeResolver): void

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

Create Subscription resolver fields

Parameters:

NameTypeDescription
modelModelDefinitionThe model definition with CRUD config and GraphQL typr
subscriptionObjIObjectTypeResolverSubscription resolver object

Returns: void


Protected addUpdateMutationResolver

addUpdateMutationResolver(model: ModelDefinition, mutationObj: IObjectTypeResolver): void

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

Creates an Update mutation resolver

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
mutationObjIObjectTypeResolverMutation resolver object

Returns: void


Protected addUpdateSubscriptionResolver

addUpdateSubscriptionResolver(modelType: GraphQLObjectType, subscriptionObj: IObjectTypeResolver): void

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

Creates an Update Subscription resolver field

Parameters:

NameTypeDescription
modelTypeGraphQLObjectTypeModel GraphQL object type
subscriptionObjIObjectTypeResolver-

Returns: void


Protected addVersionedMetadataFields

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

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

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:769

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:246

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


Protected createQueries

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

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

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


createResolvers

createResolvers(metadata: GraphbackCoreMetadata): IResolvers

Overrides void

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

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:217

Parameters:

NameType
queryTypesany
mutationTypesany
subscriptionTypesany

Returns: GraphQLSchema‹›


Private createSchemaCRUDTypes

createSchemaCRUDTypes(schemaComposer: SchemaComposer‹any›): void

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

Parameters:

NameType
schemaComposerSchemaComposer‹any›

Returns: void


Protected createSubscriptions

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

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

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:51

Parameters:

NameType
metadataGraphbackCoreMetadata

Returns: GraphQLSchema


Protected transformSchemaToString

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

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

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

Parameters:

NameTypeDescription
schemaGraphQLSchema-
fileExtensionstring

Returns: string