Options
All
  • Public
  • Public/Protected
  • All
Menu

Module graphql/server

Index

References

Interfaces

Type aliases

Functions

References

ApolloVariables

Re-exports ApolloVariables

CreateGraphqlModelOptionsShared

Re-exports CreateGraphqlModelOptionsShared

DefaultFragmentOptions

Re-exports DefaultFragmentOptions

Fragment

Re-exports Fragment

GraphqlModel

Re-exports GraphqlModel

GraphqlModelDefinition

Re-exports GraphqlModelDefinition

GraphqlModelOptions

Re-exports GraphqlModelOptions

GraphqlModelOptionsShared

Re-exports GraphqlModelOptionsShared

MultiInput

Re-exports MultiInput

MultiVariables

Re-exports MultiVariables

QueryInput

Re-exports QueryInput

RelationDefinition

Re-exports RelationDefinition

SingleInput

Re-exports SingleInput

SingleVariables

Re-exports SingleVariables

VulcanGraphqlFieldSchema

Re-exports VulcanGraphqlFieldSchema

VulcanGraphqlModel

Re-exports VulcanGraphqlModel

VulcanGraphqlModelSkeleton

Re-exports VulcanGraphqlModelSkeleton

VulcanGraphqlSchema

Re-exports VulcanGraphqlSchema

arrayToGraphQL

Re-exports arrayToGraphQL

autocompleteQueryName

Re-exports autocompleteQueryName

autocompleteQueryTemplate

Re-exports autocompleteQueryTemplate

convertToGraphQL

Re-exports convertToGraphQL

createClientTemplate

Re-exports createClientTemplate

createDataInputTemplate

Re-exports createDataInputTemplate

createDataInputType

Re-exports createDataInputType

createGraphqlModel

Re-exports createGraphqlModel

createInputTemplate

Re-exports createInputTemplate

createInputType

Re-exports createInputType

createMutationTemplate

Re-exports createMutationTemplate

createMutationType

Re-exports createMutationType

createOperationName

Re-exports createOperationName

customFilterTemplate

Re-exports customFilterTemplate

customFilterType

Re-exports customFilterType

customSortTemplate

Re-exports customSortTemplate

customSortType

Re-exports customSortType

deleteClientTemplate

Re-exports deleteClientTemplate

deleteInputTemplate

Re-exports deleteInputTemplate

deleteInputType

Re-exports deleteInputType

deleteMutationTemplate

Re-exports deleteMutationTemplate

deleteMutationType

Re-exports deleteMutationType

fieldDynamicQueryName

Re-exports fieldDynamicQueryName

fieldDynamicQueryTemplate

Re-exports fieldDynamicQueryTemplate

fieldFilterInputTemplate

Re-exports fieldFilterInputTemplate

fieldSortInputTemplate

Re-exports fieldSortInputTemplate

fieldStaticQueryTemplate

Re-exports fieldStaticQueryTemplate

fieldTemplate

Re-exports fieldTemplate

filterInputType

Re-exports filterInputType

getArguments

Re-exports getArguments

getDefaultFragmentName

Re-exports getDefaultFragmentName

getDefaultFragmentText

Re-exports getDefaultFragmentText

getFieldFragment

Re-exports getFieldFragment

getFragmentName

Re-exports getFragmentName

getModelFragment

Re-exports getModelFragment

mainTypeTemplate

Re-exports mainTypeTemplate

makeAutocomplete

Re-exports makeAutocomplete

makeCheckboxgroup

Re-exports makeCheckboxgroup

makeRadiogroup

Re-exports makeRadiogroup

multiClientTemplate

Re-exports multiClientTemplate

multiInputTemplate

Re-exports multiInputTemplate

multiInputType

Re-exports multiInputType

multiOperationName

Re-exports multiOperationName

multiOutputTemplate

Re-exports multiOutputTemplate

multiOutputType

Re-exports multiOutputType

multiQuery

Re-exports multiQuery

multiQueryTemplate

Re-exports multiQueryTemplate

multiQueryType

Re-exports multiQueryType

mutationOutputTemplate

Re-exports mutationOutputTemplate

mutationOutputType

Re-exports mutationOutputType

selectorInputTemplate

Re-exports selectorInputTemplate

selectorInputType

Re-exports selectorInputType

selectorUniqueInputTemplate

Re-exports selectorUniqueInputTemplate

selectorUniqueInputType

Re-exports selectorUniqueInputType

singleClientTemplate

Re-exports singleClientTemplate

singleInputTemplate

Re-exports singleInputTemplate

singleInputType

Re-exports singleInputType

singleOperationName

Re-exports singleOperationName

singleOutputTemplate

Re-exports singleOutputTemplate

singleOutputType

Re-exports singleOutputType

singleQueryTemplate

Re-exports singleQueryTemplate

singleQueryType

Re-exports singleQueryType

sortInputType

Re-exports sortInputType

updateClientTemplate

Re-exports updateClientTemplate

updateDataInputTemplate

Re-exports updateDataInputTemplate

updateDataInputType

Re-exports updateDataInputType

updateInputTemplate

Re-exports updateInputTemplate

updateInputType

Re-exports updateInputType

updateMutationTemplate

Re-exports updateMutationTemplate

updateMutationType

Re-exports updateMutationType

updateOperationName

Re-exports updateOperationName

upsertClientTemplate

Re-exports upsertClientTemplate

upsertInputTemplate

Re-exports upsertInputTemplate

upsertInputType

Re-exports upsertInputType

upsertMutationTemplate

Re-exports upsertMutationTemplate

upsertMutationType

Re-exports upsertMutationType

Type aliases

DefaultMutatorName

DefaultMutatorName: "create" | "update" | "delete"

GraphqlModelDefinitionServer

GraphqlModelDefinitionServer: CreateGraphqlModelOptionsServer

Server-side definition of a model

MutationResolver

MutationResolver<TVariables, TResult>: (root: any, variables: TVariables, context: any) => Promise<TResult>

Type parameters

  • TVariables = any

  • TResult = any

Type declaration

    • (root: any, variables: TVariables, context: any): Promise<TResult>
    • Parameters

      • root: any
      • variables: TVariables
      • context: any

      Returns Promise<TResult>

MutationResolverMap

MutationResolverMap: {[ resolverName in string]: QueryResolver }

QueryResolver

QueryResolver<TDocument>: (root: TDocument, args: any, context: any, info?: any) => Promise<any>

Type parameters

  • TDocument = any

Type declaration

    • (root: TDocument, args: any, context: any, info?: any): Promise<any>
    • Parameters

      • root: TDocument
      • args: any
      • context: any
      • Optional info: any

      Returns Promise<any>

QueryResolverMap

QueryResolverMap: {[ resolverName in string]: QueryResolver }

Resolver

UpdateMutatorInput

UpdateMutatorInput: UpdateMutatorCommonInput & DataIdInput | VulcanInput | SelectorInput

VulcanApolloContext

VulcanApolloContext<TContext, TDataSources>: { currentUser?: any; dataSources?: {} & TDataSources; req?: any; res?: any } & TContext

Default Vulcan Apollo Context, extend as you wish

Type parameters

  • TContext = any

  • TDataSources = any

VulcanGraphqlSchemaServer

VulcanGraphqlSchemaServer: VulcanSchema<VulcanGraphqlFieldSchemaServer>

VulcanSelector

VulcanSelector<TModel>: FieldSelector<TModel> | OperatorSelector<TModel>

Type parameters

  • TModel = any

Functions

Const buildApolloSchema

  • Parameters

    Returns { resolvers: any; typeDefs: string }

    • resolvers: any
    • typeDefs: string

buildDefaultMutationResolvers

  • Parameters

    • __namedParameters: BuildDefaultMutationResolversInput

    Returns MutationResolverDefinitions

buildDefaultQueryResolvers

  • buildDefaultQueryResolvers<TModel>(__namedParameters: BuildDefaultQueryResolversInput): Required<QueryResolverDefinitions>
  • Expect

    • context[typeName].model to contain the model (this way we don't need to have the model when we create the resolvers, this solves the problem of circular dependency)
    • context[typeName].connector to contain the connector for this model

    Type parameters

    • TModel: VulcanDocument

    Parameters

    • __namedParameters: BuildDefaultQueryResolversInput

    Returns Required<QueryResolverDefinitions>

convertIdAndTransformToJSON

  • convertIdAndTransformToJSON<TModel>(doc: MongoDoc<TModel>): TModel & { _id: string }
  • convertIdAndTransformToJSON<TModel>(docs: MongoDoc<TModel>[]): (TModel & { _id: string })[]
  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • doc: MongoDoc<TModel>

    Returns TModel & { _id: string }

  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • docs: MongoDoc<TModel>[]

    Returns (TModel & { _id: string })[]

convertToJSON

  • convertToJSON<TModel>(doc: MongoDoc<TModel>): TModel & { _id: MongoId }
  • convertToJSON<TModel>(docs: MongoDoc<TModel>[]): (TModel & { _id: MongoId })[]
  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • doc: MongoDoc<TModel>

    Returns TModel & { _id: MongoId }

  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • docs: MongoDoc<TModel>[]

    Returns (TModel & { _id: MongoId })[]

Const createContext

  • createContext(models: any): (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>) => Promise<{}>
  • Not yet used in Vulcan Next, because user might want to keep control on this Used in integration tests

    Parameters

    • models: any

    Returns (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>) => Promise<{}>

      • (req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>): Promise<{}>
      • Parameters

        • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

        Returns Promise<{}>

Const createDataSources

  • Build a default graphql context for a list of models

    NOTE: when coding custom mutation or resolvers, you DON'T need to rely on this context It is used internally by Vulcan to generate the default query and mutation resolvers, and field/relation resolvers for the dataSources

    Parameters

    Returns () => ModelDataSources

      • (): ModelDataSources
      • Returns ModelDataSources

Const createGraphqlModelServer

Const createMutator

  • createMutator<TModel>(__namedParameters: CreateMutatorInput): Promise<{ data: TModel }>
  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • __namedParameters: CreateMutatorInput

    Returns Promise<{ data: TModel }>

Const dataToModifier

  • dataToModifier(data: VulcanDocument): Modifier
  • Parameters

    • data: VulcanDocument

    Returns Modifier

Const deleteMutator

  • deleteMutator<TModel>(__namedParameters: DeleteMutatorCommonInput & { dataId: string; input?: undefined; selector?: undefined } & DeleteMutatorCommonInput & { dataId?: undefined; input?: undefined; selector: Object } & DeleteMutatorCommonInput & { dataId?: undefined; input: DeleteInput; selector?: undefined }): Promise<{ data: TModel }>
  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • __namedParameters: DeleteMutatorCommonInput & { dataId: string; input?: undefined; selector?: undefined } & DeleteMutatorCommonInput & { dataId?: undefined; input?: undefined; selector: Object } & DeleteMutatorCommonInput & { dataId?: undefined; input: DeleteInput; selector?: undefined }

    Returns Promise<{ data: TModel }>

Const extendModelServer

  • Plugin function that adds graphql options to a generic model, including server-side fields

    NOTE: should not be used directly, prefer calling "createGraphqlModelServer"

    Parameters

    Returns (model: VulcanModel<VulcanSchema<AnyObject>>) => VulcanGraphqlModelServer

Const formattedDateResolver

  • formattedDateResolver(fieldName: any): (document?: {}, args?: any, context?: any) => Promise<undefined | string>
  • Parameters

    • fieldName: any

    Returns (document?: {}, args?: any, context?: any) => Promise<undefined | string>

      • (document?: {}, args?: any, context?: any): Promise<undefined | string>
      • Parameters

        • document: {} = {}
        • args: any = {}
        • context: any = {}

        Returns Promise<undefined | string>

Const getModel

  • Get the model from graphql context (helps avoiding circular dependencies)

    Parameters

    • context: any
    • typeName: string

      The model typeName

    Returns VulcanGraphqlModelServer

Const getModelConnector

  • We expect the connectors to be already in the context

    This function is just an helper to retrieve it

    NOTE: you are not supposed to use this in an end application. Instead, directly import your model and its connector.

    Type parameters

    • TModel: VulcanDocument

    Parameters

    Returns Connector<TModel, any, any, any>

Const getModelDataSource

  • Get data source from the context.

    Type parameters

    • TDocument: VulcanDocument

    Parameters

    Returns VulcanGenericDataSource<TDocument>

Const getUnusedSlug

  • getUnusedSlug(connector: Connector<any, any, any, any>, slug: any, documentId: any): Promise<undefined | string>
  • Parameters

    • connector: Connector<any, any, any, any>
    • slug: any
    • documentId: any

    Returns Promise<undefined | string>

Const mergeModelDefinitionServer

Const modifierToData

  • modifierToData(modifier: Modifier): VulcanDocument
  • Parameters

    • modifier: Modifier

    Returns VulcanDocument

Const performMutationCheck

  • performMutationCheck(options: MutationCheckOptions): void
  • Parameters

    • options: MutationCheckOptions

    Returns void

Const updateMutator

  • Type parameters

    • TModel: VulcanDocument

    Parameters

    Returns Promise<{ data: TModel }>

Const validateData

  • validateData(__namedParameters: ValidateDataInput): ValidationError[]
  • Parameters

    • __namedParameters: ValidateDataInput

    Returns ValidationError[]

Const validateMutationData

  • validateMutationData(__namedParameters: { currentUser?: any; data?: any; model: VulcanCrudModelServer<any>; mutatorName: DefaultMutatorName; originalDocument?: VulcanDocument; properties: Partial<CreateMutatorProperties & UpdateMutatorProperties>; validationFunction?: Function }): Promise<void>
  • Parameters

    • __namedParameters: { currentUser?: any; data?: any; model: VulcanCrudModelServer<any>; mutatorName: DefaultMutatorName; originalDocument?: VulcanDocument; properties: Partial<CreateMutatorProperties & UpdateMutatorProperties>; validationFunction?: Function }
      • Optional currentUser?: any
      • Optional data?: any
      • model: VulcanCrudModelServer<any>
      • mutatorName: DefaultMutatorName
      • Optional originalDocument?: VulcanDocument
      • properties: Partial<CreateMutatorProperties & UpdateMutatorProperties>
      • Optional validationFunction?: Function

    Returns Promise<void>

Generated using TypeDoc