Version: next

GraphbackCRUDService

Graphback layered architecture component that can be called from the resolver layer in GraphQL and Middlerware layer in RESTfull approach.

Graphback implements server side procesing using following flow:

GraphQL Resolvers -> GraphbackCRUDService [1-*] -> GraphbackDataProvider

Services can be composable (each service can reference multiple layers of other services). For data abstraction Graphback GraphbackDataProvider can be being used.

see GraphbackDataProvider

Type parameters

Type

GraphbackContext

Hierarchy

  • GraphbackCRUDService

Implemented by

Index

Methods

Methods

batchLoadData

batchLoadData(relationField: string, id: string | number, filter: any, context: any): any

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:102

Speciallized function that can utilize batching the data basing on DataLoader library

Parameters:

NameTypeDescription
relationFieldstringname of the field that will be used to match ids
idstring | numberid of the object we want to load
filterany-
contextanyresolver context object that will be used to apply new loader

Returns: any


create

create(data: Type, context: GraphbackContext): Promise‹Type›

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:32

Implementation for object creation

Parameters:

NameTypeDescription
dataTypeinput data
contextGraphbackContextcontext object passed from graphql or rest layer

Returns: Promise‹Type›


delete

delete(data: Type, context: GraphbackContext): Promise‹Type›

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:48

Implementation for object deletes

Parameters:

NameTypeDescription
dataTypedata used for consistency reasons
contextGraphbackContextcontext object passed from graphql or rest layer

Returns: Promise‹Type›


findBy

findBy(filter: QueryFilter‹Type›, context: GraphbackContext, page?: GraphbackPage, orderBy?: any): Promise‹ResultList‹Type››

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:66

Implementation for reading objects with filtering capabilities

Parameters:

NameTypeDescription
filterQueryFilter‹Type›filter by specific type
contextGraphbackContextcontext object passed from graphql or rest layer
page?GraphbackPagepagination options
orderBy?anyoptionally sort the results by a column

Returns: Promise‹ResultList‹Type››


findOne

findOne(filter: Type, context: GraphbackContext): Promise‹Type›

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:56

Fetch a single record by its unique attribute(s)

Parameters:

NameTypeDescription
filterTypethe unique attributes to fetch the record with
contextGraphbackContextcontext object from GraphQL/REST layer

Returns: Promise‹Type›


subscribeToCreate

subscribeToCreate(filter?: any, context?: GraphbackContext): AsyncIterator‹Type› | undefined

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:74

Subscription for all creation events

Parameters:

NameTypeDescription
filter?anyfilter used in subscription
context?GraphbackContextadditional context

Returns: AsyncIterator‹Type› | undefined


subscribeToDelete

subscribeToDelete(filter?: any, context?: GraphbackContext): AsyncIterator‹Type› | undefined

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:90

Subscription for all deletion events

Parameters:

NameTypeDescription
filter?anyfilter used in subscription
context?GraphbackContextadditional context

Returns: AsyncIterator‹Type› | undefined


subscribeToUpdate

subscribeToUpdate(filter?: any, context?: GraphbackContext): AsyncIterator‹Type› | undefined

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:82

Subscription for all update events

Parameters:

NameTypeDescription
filter?anyfilter used in subscription
context?GraphbackContextadditional context

Returns: AsyncIterator‹Type› | undefined


update

update(data: Type, context: GraphbackContext): Promise‹Type›

Defined in packages/graphback-core/src/runtime/GraphbackCRUDService.ts:40

Implementation for object updates

Parameters:

NameTypeDescription
dataTypeinput data including id
contextGraphbackContextcontext object passed from graphql or rest layer

Returns: Promise‹Type›