Version: Next

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

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

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

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

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

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

Creates a Find Query resolver field

Parameters:

NameTypeDescription
modelModelDefinitionModel definition object
queryObjIObjectTypeResolver-

Returns: void


Protected addMutationResolvers#

addMutationResolvers(model: ModelDefinition, resolvers: IResolvers): 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
resolversIResolversroot resolver object

Returns: void


Protected addOneToManyResolver#

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

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

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, resolvers: IResolvers): void

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

Create Query resolver fields

Parameters:

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

Returns: void


Protected addRelationshipResolvers#

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

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

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, resolvers: IResolvers): void

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

Create Subscription resolver fields

Parameters:

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

Returns: void


Protected addUpdateMutationResolver#

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

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

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

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

Parameters:

NameType
schemaComposerSchemaComposer‹any›
modelsModelDefinition[]

Returns: void


Protected buildSchemaForModels#

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

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

Parameters:

NameType
schemaComposerSchemaComposer‹any›
modelsModelDefinition[]

Returns: void


Private buildSchemaModelRelationships#

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

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

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

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


Protected createQueries#

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

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

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

Parameters:

NameType
metadataGraphbackCoreMetadata

Returns: void


Protected createSchema#

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

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

Parameters:

NameType
queryTypesany
mutationTypesany
subscriptionTypesany

Returns: GraphQLSchema‹›


Private createSchemaCRUDTypes#

createSchemaCRUDTypes(schemaComposer: SchemaComposer‹any›): void

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

Parameters:

NameType
schemaComposerSchemaComposer‹any›

Returns: void


Protected createSubscriptions#

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

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

Parameters:

NameType
modelModelDefinition
schemaComposerSchemaComposer‹any›

Returns: void


getPluginName#

getPluginName(): string

Overrides void

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

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

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

Parameters:

NameTypeDescription
schemaGraphQLSchema-
fileExtensionstring

Returns: string