GraphQLService
Class: GraphQLService<T>
Defined in: graphql/src/graphql.service.ts:284
Implement a GraphQL service
It will expose all your exposed models as GraphQL types Dynamically generate the schema
Webda Modda
Extends
DomainService<T>
Type Parameters
T
T extends GraphQLParameters = GraphQLParameters
Constructors
Constructor
new GraphQLService<
T>(name,params):GraphQLService<T>
Defined in: core/lib/services/service.d.ts:72
Service
Parameters
name
string
The name of the service
params
T
The parameters block define in the configuration file
Returns
GraphQLService<T>
Inherited from
DomainService<T>.constructor
Properties
_compiledCapabilities
protected_compiledCapabilities:Record<string,any>
Defined in: core/lib/services/iservice.d.ts:38
Capabilities detected at compile-time from @WebdaCapability-tagged interfaces.
Populated during Service.resolve by reading the service's entry in
webda.module.json. Each key is a capability name (e.g., "request-filter"),
and the value is an empty object {} by default. Override getCapabilities
to provide capability-specific configuration or to conditionally disable capabilities.
See
getCapabilities
Inherited from
DomainService._compiledCapabilities
[WEBDA_EVENTS]
[WEBDA_EVENTS]:
DomainServiceEvents
Defined in: core/lib/services/service.d.ts:50
Set the Webda events here
Inherited from
DomainService.[WEBDA_EVENTS]
app
app:
Application
Defined in: graphql/src/graphql.service.ts:296
Overrides
DomainService.app
handler?
optionalhandler?:Handler
Defined in: graphql/src/graphql.service.ts:286
logger
protectedlogger:Logger
Defined in: core/lib/services/service.d.ts:59
Logger with class context
Inherited from
DomainService.logger
metrics?
protectedoptionalmetrics?:object
Defined in: core/lib/services/service.d.ts:63
Get metrics
Inherited from
DomainService.metrics
modelFields
modelFields:
Record<string,GraphQLModelFields> ={}
Defined in: graphql/src/graphql.service.ts:307
The CRUD fields generateSchema() gave to each exposed model, by model id
modelListeners
modelListeners:
any
Defined in: graphql/src/graphql.service.ts:299
modelsMap
modelsMap:
object
Defined in: graphql/src/graphql.service.ts:287
Index Signature
[key: string]: GraphQLObjectType<any, any>
name
readonlyname:string
Defined in: core/lib/services/iservice.d.ts:18
Inherited from
DomainService.name
namedTypes
namedTypes:
Map<string, {shape:string;type?:GraphQLType; }>
Defined in: graphql/src/graphql.service.ts:295
Generated named types, by name: a name is generated once per shape (reset by generateSchema)
operationPlacements
operationPlacements:
Record<string,GraphQLPlacement> ={}
Defined in: graphql/src/graphql.service.ts:303
Where generateSchema() exposed each operation, by operation id (the model CRUD excepted, see modelFields)
parameters
readonlyparameters:T
Defined in: core/lib/services/iservice.d.ts:19
Inherited from
DomainService.parameters
queryTotalType?
protectedoptionalqueryTotalType?:GraphQLObjectType<any,any>
Defined in: graphql/src/graphql.service.ts:291
Type of the total field of the query results (reset by generateSchema)
schema
schema:
GraphQLSchema
Defined in: graphql/src/graphql.service.ts:285
wsHandler
wsHandler:
Server
Defined in: graphql/src/graphql.service.ts:298
wss
wss:
WebSocketServer
Defined in: graphql/src/graphql.service.ts:297
filterConfiguration?
staticoptionalfilterConfiguration?: (params) =>any
Defined in: core/lib/services/iservice.d.ts:27
Create configuration set by the application on load
Parameters
params
any
Returns
any
Inherited from
DomainService.filterConfiguration
Parameters
staticParameters: typeofServiceParameters
Defined in: core/lib/services/service.d.ts:46
Service parameters
Inherited from
DomainService.Parameters
schemas
staticschemas:object
Defined in: core/lib/services/domainservice.service.d.ts:147
searchRequest
searchRequest:
object
searchRequest.properties
properties:
object
searchRequest.properties.count
count:
object
searchRequest.properties.count.type
type:
string
searchRequest.properties.query
query:
object
searchRequest.properties.query.type
type:
string
searchRequest.type
type:
string
uuidRequest
uuidRequest:
object
uuidRequest.properties
properties:
object
uuidRequest.properties.uuid
uuid:
object
uuidRequest.properties.uuid.type
type:
string
uuidRequest.required
required:
string[]
uuidRequest.type
type:
string
Inherited from
DomainService.schemas
Methods
__clean()
abstract__clean():Promise<void>
Defined in: core/lib/services/service.d.ts:215
Clean the service data, can only be used in test mode
Returns
Promise<void>
Inherited from
DomainService.__clean
actionInput()
protectedactionInput(modelKey,name):any
Defined in: core/lib/services/domainservice.service.d.ts:290
The .input schema of an action, when it describes its parameters
A module built before x-webda-context expanded an OperationContext parameter into the schema: such an
action is treated as taking the context only, as before.
Parameters
modelKey
string
model identifier
name
string
action name
Returns
any
the input schema, undefined when the action takes no input or has an old-style schema
Inherited from
DomainService.actionInput
actionRequestSchema()
protectedactionRequestSchema(modelKey,name,input):string
Defined in: core/lib/services/domainservice.service.d.ts:311
Register the input schema of an instance action operation: the object uuid and the action parameters
The uuid comes first in x-webda-arguments: modelAction loads the object with it and passes the rest
to the action method.
Parameters
modelKey
string
model identifier
name
string
action name
input
any
the action .input schema (its parameters)
Returns
string
the registered schema name, <modelKey>.<name>.request
Throws
Error when an action parameter is named uuid
Inherited from
DomainService.actionRequestSchema
addBehaviorOperations()
addBehaviorOperations(
model,Metadata,name):void
Defined in: core/lib/services/domainservice.service.d.ts:338
Register one operation per declared action on every Behavior attribute of
the model. Operation ids follow the <Model>.<Attribute>.<Action> shape
so transports can discover them with the same lookup logic used for
model-level operations.
The actual dispatch is deferred to modelBehaviorAction. This method
only wires the registry entries — it does not invoke behaviors.
Parameters
model
ModelClass<Model>
the model class owning the behavior attribute
Metadata
any
the model metadata blob (with Relations.behaviors)
name
string
the model's short identifier (e.g. "User")
Returns
void
Inherited from
DomainService.addBehaviorOperations
addListener()
addListener<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:80
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
eventName
Key
the event name
listener
(event) => void | Promise<void>
the event listener
Returns
this
this for chaining
See
EventEmitter.addListener
Inherited from
DomainService.addListener
addOperationFields()
addOperationFields(
rootFields,mutations,subscriptions):void
Defined in: graphql/src/graphql.service.ts:1256
Expose the registered operations, except the model CRUD the model schema already serves: read-only ones as queries, the others as mutations, server-streaming ones as subscriptions
Parameters
rootFields
GraphQLFieldConfigMap<any, any>
query fields
mutations
GraphQLFieldConfigMap<any, any>
mutation fields
subscriptions
GraphQLFieldConfigMap<any, any>
subscription fields
Returns
void
Throws
Error when a field name is already defined
addRoute()
protectedaddRoute(url,methods,executer,openapi?,override?):void
Defined in: core/lib/services/service.d.ts:177
Add a route dynamicaly
Parameters
url
string
of the route can contains dynamic part like {uuid}
methods
HttpMethodType[]
the HTTP methods
executer
Function
Method to execute for this route
openapi?
OpenAPIWebdaDefinition
the OpenAPI specification
override?
boolean
whether to override existing
Returns
void
Inherited from
DomainService.addRoute
assertFilterQuery()
assertFilterQuery(
query):void
Defined in: graphql/src/graphql.service.ts:1510
Refuse a query argument that is not a filter: DELETE and UPDATE are never run from GraphQL, and a SELECT field list is refused because the selection set already chooses the fields
A query that does not parse is left to the query path, which reports it as before.
Parameters
query
string
the client query
Returns
void
Throws
GraphQLError BAD_USER_INPUT for a DELETE, an UPDATE or a SELECT field list
authorizeClientEvent()
authorizeClientEvent(
_event,_context):boolean
Defined in: core/lib/services/service.d.ts:153
Authorize a public event subscription
Parameters
_event
string
the event name
_context
OperationContext
the execution context
Returns
boolean
true if the condition is met
Inherited from
DomainService.authorizeClientEvent
checkParent()
protectedcheckParent(model,parentId,context):Promise<void>
Defined in: core/lib/services/domainservice.service.d.ts:220
checkModelParent, emitting Store.WebNotFound when the parent is missing or unreadable, like any missing
object
Parameters
model
ModelClass<Model>
the child model class
parentId
any
the parent primary key
context
OperationContext
the caller context
Returns
Promise<void>
Inherited from
DomainService.checkParent
checkPermission()
protectedcheckPermission(object,context,action,model?):Promise<void>
Defined in: core/lib/services/domainservice.service.d.ts:192
checkModelPermission, emitting Store.WebNotFound when the refusal looks like a missing object, exactly
like loadModel does for a missing key
Parameters
object
Model
the model instance
context
OperationContext
the caller context
action
string
the action
model?
ModelClass<Model>
the model class (the static canAct asked)
Returns
Promise<void>
Inherited from
DomainService.checkPermission
checkReparent()
protectedcheckReparent(model,object,input,context):Promise<void>
Defined in: core/lib/services/domainservice.service.d.ts:238
When an update moves an object to another parent, the caller must be able to read the new parent
Parameters
model
ModelClass<Model>
the model class
object
Model
the stored object
input
any
the sanitized input
context
OperationContext
the caller context
Returns
Promise<void>
Inherited from
DomainService.checkReparent
computeParameters()
computeParameters():
void
Defined in: core/lib/services/service.d.ts:77
Used to compute or derivate input parameter to attribute
Returns
void
Deprecated
Inherited from
DomainService.computeParameters
countOperation()
countOperation(
context,increment?):void
Defined in: graphql/src/graphql.service.ts:826
Increment the operation counter and throw if the per-request limit is exceeded
Parameters
context
WebContext
web context holding the graphql extension with the counter
increment?
number = 1
number of operations to add (default 1)
Returns
void
createHandlers()
protectedcreateHandlers():void
Defined in: graphql/src/graphql.service.ts:1801
Create the HTTP and WebSocket handlers serving the current schema
Returns
void
emit()
emit<
Key>(event,data):Promise<void>
Defined in: core/lib/services/service.d.ts:204
Emit the event with data and wait for Promise to finish if listener returned a Promise
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
event
Key
the event name
data
DomainServiceEvents[Key]
the data to process
Returns
Promise<void>
Inherited from
DomainService.emit
endpoint()
endpoint(
ctx):Promise<void>
Defined in: graphql/src/graphql.service.ts:1877
Handle POST requests to the GraphQL endpoint
Parameters
ctx
WebContext<any>
incoming web context with the GraphQL query body
Returns
Promise<void>
generateSchema()
generateSchema():
void
Defined in: graphql/src/graphql.service.ts:893
Generate GraphQL schema
Returns
void
getCapabilities()
getCapabilities():
Record<string,any>
Defined in: core/lib/services/iservice.d.ts:60
Return the capabilities of this service.
By default returns capabilities detected at compile-time from
Returns
Record<string, any>
the result
Webda Capability-tagged
interfaces in webda.module.json.
Override to disable capabilities based on configuration:
getCapabilities() {
const caps = super.getCapabilities();
if (!this.parameters.enabled) delete caps["request-filter"];
return caps;
}
Inherited from
DomainService.getCapabilities
getClientEvents()
getClientEvents():
string[]
Defined in: core/lib/services/service.d.ts:144
Return the events that an external system can subscribe to
Returns
string[]
the list of results
Inherited from
DomainService.getClientEvents
getCurrentUserModel()
protectedgetCurrentUserModel(context):Promise<ModelDefinition<any>>
Defined in: graphql/src/graphql.service.ts:1433
Model definition of the current user, for the Me subscriptions
Parameters
context
WebContext
the caller context
Returns
Promise<ModelDefinition<any>>
the model of the current user
Throws
GraphQLError when the user class is not a registered model
getGraphQLFieldsFromSchema()
getGraphQLFieldsFromSchema(
schema,defaultName,webdaGraph?,input?,writable?):any
Defined in: graphql/src/graphql.service.ts:555
Build GraphQL field definitions from a JSON Schema, enriching with relation resolvers from the model graph
Parameters
schema
JSONSchema7
JSON Schema describing the model properties
defaultName
string
fallback name for generated types
webdaGraph?
ModelGraph
model relation graph (links, maps, queries, parent)
input?
boolean
if true, generate input types (skip readonly fields, skip relation resolvers)
writable?
string[] = []
_-prefixed attributes the model accepts from clients (input types only)
Returns
any
map of field names to GraphQL field configs
getGraphQLQueryResult()
getGraphQLQueryResult(
type):GraphQLObjectType
Defined in: graphql/src/graphql.service.ts:510
Get or create a GraphQL query result wrapper type with results array, continuationToken and total
total is resolved only when selected: the count query runs only then. It is null when the model does not allow
a total (see countModelWithPermissions).
Parameters
type
GraphQLObjectType
GraphQL object type to wrap in a query result
Returns
GraphQLObjectType
GraphQL object type with results, continuationToken and total fields
getGraphQLQueryTotal()
getGraphQLQueryTotal():
GraphQLObjectType
Defined in: graphql/src/graphql.service.ts:535
Get or create the GraphQL type of a query total
Returns
GraphQLObjectType
the QueryTotal type: { value: Int!, relation: String! }
getGraphQLSchema()
getGraphQLSchema(
rootFields,mutations?,subscription?):GraphQLSchema
Defined in: graphql/src/graphql.service.ts:1734
Assemble the final GraphQLSchema from root query fields, mutations, and subscriptions
Parameters
rootFields
ThunkObjMap<GraphQLFieldConfig<any, any, any>>
top-level query fields
mutations?
ThunkObjMap<GraphQLFieldConfig<any, any, any>> = {}
mutation fields
subscription?
ThunkObjMap<GraphQLFieldConfig<any, any, any>> = {}
subscription fields
Returns
GraphQLSchema
the constructed GraphQLSchema
getGraphQLSchemaFromSchema()
getGraphQLSchemaFromSchema(
schema,defaultName,input?): {description?:string;type:GraphQLType; } |undefined
Defined in: graphql/src/graphql.service.ts:393
Convert a JSON Schema to a GraphQL type definition
Parameters
schema
JSONSchema7
JSON Schema to convert
defaultName
string
fallback name for anonymous types
input?
boolean
if true, generate GraphQLInputObjectType instead of GraphQLObjectType
Returns
{ description?: string; type: GraphQLType; } | undefined
object with the GraphQL type and optional description, or undefined for null types
getJsonSchemaDefinition()
getJsonSchemaDefinition(
prop,definitions?):JSONSchema7
Defined in: graphql/src/graphql.service.ts:332
Resolve a JSON Schema property by following $ref pointers
Parameters
prop
JSONSchema7
JSON Schema property that may contain $ref
definitions?
Record<string, JSONSchema7Definition> = {}
schema definitions map for resolving references
Returns
JSONSchema7
the resolved JSON Schema (or a null type if unresolvable)
getMaxListeners()
getMaxListeners():
number
Defined in: core/lib/events/asynceventemitter.d.ts:84
Returns
number
Inherited from
DomainService.getMaxListeners
getMetric()
getMetric<
T>(type,configuration):T
Defined in: core/lib/services/service.d.ts:138
Add service name label
Type Parameters
T
T = Gauge<string> | Counter<string> | Histogram<string>
Parameters
type
CustomConstructor<T, [MetricConfiguration<T>]>
the type to look up
configuration
MetricConfiguration<T>
the configuration
Returns
T
the result
Inherited from
DomainService.getMetric
getModelInput()
protectedgetModelInput(context):Promise<any>
Defined in: core/lib/services/domainservice.service.d.ts:205
The model input of a create, update or patch: always the full request body
The CRUD methods take no argument: resolveArguments spreads the model schema's properties into positional args, so the first one is only the value of the first property, which may itself be an object or an array (#911).
An empty body (undefined) is accepted as "no fields"; any other body that is not a plain object (array, string, number, boolean or null) is refused.
Parameters
context
OperationContext
the operation context
Returns
Promise<any>
the request body
Throws
BadRequest when the body is not an object
Inherited from
DomainService.getModelInput
getName()
getName():
string
Defined in: core/lib/services/service.d.ts:209
Get service name
Returns
string
the result string
Inherited from
DomainService.getName
getOpenApiReplacements()
getOpenApiReplacements():
any
Defined in: core/lib/services/service.d.ts:182
Return variables for replacement in openapi
Returns
any
the result
Inherited from
DomainService.getOpenApiReplacements
getOperationId()
getOperationId(
id):string|undefined
Defined in: core/lib/services/service.d.ts:167
If undefined is returned it cancel the operation registration
Parameters
id
string
the identifier
Returns
string | undefined
the result
Inherited from
DomainService.getOperationId
getParameters()
getParameters():
T
Defined in: core/lib/services/service.d.ts:82
Get the service parameters
Returns
T
the result
Inherited from
DomainService.getParameters
getService()
getService<
T>(name):ServicesMap[T]
Defined in: core/lib/services/service.d.ts:131
Get a service by name
Type Parameters
T
T extends keyof ServicesMap
Parameters
name
T
the name to use
Returns
ServicesMap[T]
the result map
Deprecated
Use useService, might reconsider
Inherited from
DomainService.getService
getState()
getState():
ServiceStates
Defined in: core/lib/services/service.d.ts:55
Get the current state
Returns
ServiceStates
the result
Inherited from
DomainService.getState
getSubscribedEvents()
getSubscribedEvents(
info):string[]
Defined in: graphql/src/graphql.service.ts:1449
Extract the list of event names from the GraphQL selection set (excluding latestEventTime)
Parameters
info
GraphQLResolveInfo
GraphQL resolve info containing field selections
Returns
string[]
array of event name strings the client subscribed to
getUrl()
getUrl(
url,_methods):string
Defined in: core/lib/services/service.d.ts:161
Return the full path url based on parameters
Parameters
url
string
relative url to service
_methods
HttpMethodType[]
in case we need filtering (like Store)
Returns
string
absolute url or undefined if need to skip the Route
Inherited from
DomainService.getUrl
graphQLNames()
protectedgraphQLNames(keys,type):Map<string,string>
Defined in: graphql/src/graphql.service.ts:477
GraphQL names of the properties of a type, see graphQLNames: a JSON key that is not a GraphQL name
(available-balance) is exposed as availableBalance, unless that name is taken (logged, left out)
Parameters
keys
string[]
the property keys
type
string
the type holding them, for the log
Returns
Map<string, string>
the GraphQL name of each key exposed
handleModel()
handleModel(
model,name,context):boolean
Defined in: graphql/src/graphql.service.ts:1826
Check whether a model should be handled by this service (always returns true)
Parameters
model
ModelDefinition<any>
model class to check
name
string
display name of the model
context
any
request context
Returns
boolean
true if the model should be processed
handleSocketMessage()
handleSocketMessage(
socket,cb,data,storage):Promise<void>
Defined in: graphql/src/graphql.service.ts:1706
Hand a WebSocket message to graphql-ws; a failure is logged and closes the socket without leaking details
Parameters
socket
Pick<WebSocket, "close">
the WebSocket
cb
(data) => Promise<void>
the graphql-ws message handler
data
string
the message
storage
ReturnType<typeof useInstanceStorage>
the instance storage to re-enter for the resolvers
Returns
Promise<void>
a promise settled once the message is handled
hasActionInput()
protectedhasActionInput(model,action):boolean
Defined in: core/lib/services/domainservice.service.d.ts:278
Whether an action has an input schema, so it receives its parameters rather than the context
Parameters
model
ModelClass<Model>
the model class
action
the action
name
string
the action name
Returns
boolean
true when <model>.<action>.input exists
Inherited from
DomainService.hasActionInput
init()
init():
Promise<GraphQLService<T>>
Defined in: graphql/src/graphql.service.ts:1763
Returns
Promise<GraphQLService<T>>
Overrides
DomainService.init
initMetrics()
initMetrics():
void
Defined in: core/lib/services/service.d.ts:124
Init the metrics
Returns
void
Inherited from
DomainService.initMetrics
initOperations()
initOperations():
void
Defined in: core/lib/services/domainservice.service.d.ts:324
Add operations for all exposed models
Returns
void
the result
Inherited from
DomainService.initOperations
isExposable()
isExposable(
model,identifier):boolean
Defined in: core/lib/services/domainservice.service.d.ts:319
Whether a model may be exposed: models of INTERNAL_MODELS and their subclasses need an explicit listing
in the models parameter
Parameters
model
any
model class
identifier
string
model identifier
Returns
boolean
true when the model may be exposed
Inherited from
DomainService.isExposable
listeners()
listeners(
eventName):Function[]
Defined in: core/lib/events/asynceventemitter.d.ts:139
Get all listeners for an event
Parameters
eventName
"Store.WebNotFound"
the event name
Returns
Function[]
the list of results
Inherited from
DomainService.listeners
loadCapabilities()
protectedloadCapabilities():void
Defined in: core/lib/services/service.d.ts:120
Load capabilities from webda.module.json metadata into _compiledCapabilities.
Called during resolve after dependency injection. Reads the service's
type name from parameters, looks it up in the application's module metadata
(moddas or beans section), and populates _compiledCapabilities with an
empty object for each declared capability name.
Fails silently if the application is not available (e.g., in unit tests where services are instantiated without a full application context).
Returns
void
Example
// If webda.module.json contains:
// { "moddas": { "MyApp/HawkService": { "capabilities": ["request-filter", "cors-filter"] } } }
// Then after resolve(), this.getCapabilities() returns:
// { "request-filter": {}, "cors-filter": {} }
See
getCapabilities
Inherited from
DomainService.loadCapabilities
loadListedInstance()
loadListedInstance(
knownFieldsOrId,model,context,info?,filter?):Promise<any>
Defined in: graphql/src/graphql.service.ts:745
loadModelInstance for an element of a list (links, maps): an element the caller may not read, or that no longer exists, is dropped (null) instead of failing the whole list, like a filtered query
Parameters
knownFieldsOrId
string | {[key: string]: any; uuid: string; }
UUID string or object with known field values
model
ModelDefinition<any>
model class to load from
context
WebContext
web context for permission checks
info?
FieldNode
GraphQL field node describing the selection set
filter?
PartialValidator
optional WebdaQL filter to apply to the result
Returns
Promise<any>
the model instance, or null
loadModelInstance()
loadModelInstance(
knownFieldsOrId,model,context,info?,filter?):Promise<any>
Defined in: graphql/src/graphql.service.ts:771
Load a model instance, optimizing to skip store reads when all requested fields are already known
Parameters
knownFieldsOrId
string | {[key: string]: any; uuid: string; }
UUID string or object with known field values
model
ModelDefinition<any>
model class to load from
context
WebContext
web context for permission checks
info?
FieldNode
GraphQL field node describing the selection set
filter?
PartialValidator
optional WebdaQL filter to apply to the result
Returns
Promise<any>
the model instance, or null if filtered out
loadParameters()
loadParameters(
params):GraphQLParameters
Defined in: graphql/src/graphql.service.ts:313
Load and initialize GraphQL service parameters
Parameters
params
any
raw partial configuration
Returns
initialized GraphQLParameters
log()
log(
level, ...args):void
Defined in: core/lib/services/service.d.ts:226
Parameters
level
WorkerLogLevel
to log
args
...any[]
additional arguments
Returns
void
Inherited from
DomainService.log
modelAction()
modelAction(...
args):Promise<any>
Defined in: core/lib/services/domainservice.service.d.ts:299
Action on a model
An instance action receives uuid first (to load the object) then its parameters; a static action its
parameters. Actions without an input schema receive the context.
Parameters
args
...any[]
arguments forwarded to the action method
Returns
Promise<any>
the action result
Inherited from
DomainService.modelAction
modelBehaviorAction()
modelBehaviorAction(...
args):Promise<any>
Defined in: core/lib/services/domainservice.service.d.ts:364
Dispatcher for a behavior-attribute action registered by
addBehaviorOperations. Mirrors the shape of modelAction:
- read the parent model class + attribute/action names off
operationContext(set up bycallOperation), - take
args[0]as the parent UUID (Behavior actions are always instance-scoped per the spec), - load the parent via
model.ref(uuid).get()—NotFoundif missing or soft-deleted, - ask the model whether the action is allowed via
canAct(ctx, "<attribute>.<action>")— anything buttrue(or the instance itself, the convention some models use to say "yes, on this object") is treated as a denial, - read
instance[attribute]— already a hydrated Behavior instance thanks toCoreModel.deserialize(Task 7), - call
behaviorInstance[action](...args.slice(1))and letcallOperationwrite the result onto the context.
Parameters
args
...any[]
resolved arguments from resolveArguments; the first is
always the parent UUID, the rest come from the request body / query
params depending on the registered input schema.
Returns
Promise<any>
the Behavior method's return value (callOperation writes it to the context output if non-undefined).
Inherited from
DomainService.modelBehaviorAction
modelCreate()
modelCreate():
Promise<Model>
Defined in: core/lib/services/domainservice.service.d.ts:212
Create a model operation implementation
The model data is the request body (getModelInput)
Returns
Promise<Model>
the created model instance
Inherited from
DomainService.modelCreate
modelDelete()
modelDelete(
uuid):Promise<void>
Defined in: core/lib/services/domainservice.service.d.ts:256
Delete a model operation implementation
Parameters
uuid
string
the model primary key
Returns
Promise<void>
Inherited from
DomainService.modelDelete
modelGet()
modelGet(
uuid):Promise<Model>
Defined in: core/lib/services/domainservice.service.d.ts:251
Get a model operation implementation
Parameters
uuid
string
the model primary key
Returns
Promise<Model>
the model instance
Inherited from
DomainService.modelGet
modelPatch()
modelPatch():
Promise<Model>
Defined in: core/lib/services/domainservice.service.d.ts:270
Patch a model
The partial update data is the request body (getModelInput)
Returns
Promise<Model>
the patched model instance
Inherited from
DomainService.modelPatch
modelQuery()
modelQuery(
query,count?):Promise<any>
Defined in: core/lib/services/domainservice.service.d.ts:263
Query models
Parameters
query
string
the query string
count?
boolean
also return the total of the query (total), when the model allows it
Returns
Promise<any>
the query results
Inherited from
DomainService.modelQuery
modelUpdate()
modelUpdate():
Promise<Model>
Defined in: core/lib/services/domainservice.service.d.ts:245
Update a model operation implementation
The update data is the request body (getModelInput)
Returns
Promise<Model>
the updated model instance
Inherited from
DomainService.modelUpdate
namedType()
namedType<
T>(name,shape,create):T
Defined in: graphql/src/graphql.service.ts:353
One GraphQL type per name: reuse the type already generated for this name and shape
Type Parameters
T
T extends GraphQLType
Parameters
name
string
type name
shape
string
what makes two types of this name the same (kind and field names)
create
() => T
builds the type the first time
Returns
T
the type
Throws
Error when the name was generated for another shape
off()
off<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:116
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.off
Inherited from
DomainService.off
on()
on<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:102
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.once
Inherited from
DomainService.on
once()
once<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:95
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.once
Inherited from
DomainService.once
operationArgs()
operationArgs(
op,base):object
Defined in: graphql/src/graphql.service.ts:1314
GraphQL arguments of an operation: one per input schema property, or a single input argument
Parameters
op
OperationDefinition
operation
base
string
type name prefix
Returns
object
the arguments and how to turn them back into the operation input
args
args:
GraphQLFieldConfigArgumentMap
toInput
toInput: (
args) =>unknown
Parameters
args
Record<string, unknown>
Returns
unknown
operationOutputType()
operationOutputType(
op,base):GraphQLOutputType
Defined in: graphql/src/graphql.service.ts:1363
GraphQL type of an operation result
Parameters
op
OperationDefinition
operation
base
string
type name prefix
Returns
GraphQLOutputType
the model type for a model output, Boolean for void, else the converted output schema
parseFilter()
parseFilter(
filter?):PartialValidator|undefined
Defined in: graphql/src/graphql.service.ts:719
Parse the filter argument of a links or maps field: WebdaQL evaluated on the linked objects, which may not read
private (__) fields
Parameters
filter?
string
the client filter
Returns
PartialValidator | undefined
the validator, undefined without filter
Throws
GraphQLError BAD_USER_INPUT for an invalid filter, one reading private fields, or a statement (DELETE, UPDATE, SELECT field list): GraphQL selection sets choose the fields
queryModel()
queryModel(
model,query,context):Promise<QueryResultWithTotal>
Defined in: graphql/src/graphql.service.ts:1483
Run a root query argument: the DomainService query with the caller permissions
Parameters
model
any
the model class
query
string
the client query
context
any
the caller context
Returns
Promise<QueryResultWithTotal>
the readable results
Throws
GraphQLError BAD_USER_INPUT for a statement (DELETE, UPDATE, SELECT field list)
queryRelated()
queryRelated(
related,model,query,context):Promise<QueryResultWithTotal>
Defined in: graphql/src/graphql.service.ts:1465
Query a 1:n relation (ModelRelated) as the caller: the relation condition is merged into the client query, then filtered like any model query (permission query, canAct "get")
Parameters
related
the ModelRelated attribute of the source object
getQuery
(query) => string
merges the relation condition into a query
model
any
the target model class
query
string
the client query
context
any
the caller context
Returns
Promise<QueryResultWithTotal>
the readable related objects
registerAsyncEventIterator()
registerAsyncEventIterator(
model,uuid,events,context,identifier):Promise<AsyncIterator<any,any,any>>
Defined in: graphql/src/graphql.service.ts:1650
Create an async iterator for raw model events (not full objects), filtered by event name and UUID
Parameters
model
ModelDefinition<any>
model class to listen on
uuid
string | null
UUID to filter events for, or null for all instances
events
string[]
list of event names the client wants to receive
context
any
web context for authorization checks
identifier
string
key used as the iterator prefix
Returns
Promise<AsyncIterator<any, any, any>>
async iterator yielding event payloads with latestEventTime
registerAsyncIterator()
registerAsyncIterator(
model,uuid,context,identifier?):Promise<AsyncIterator<any,any,any>>
Defined in: graphql/src/graphql.service.ts:1599
Create an async iterator that streams a single model instance, updating on store events
Parameters
model
ModelDefinition<any>
model class the instance belongs to
uuid
any
UUID of the specific instance to watch
context
any
web context for permission checks
identifier?
string
optional key used as the iterator prefix (defaults to model identifier)
Returns
Promise<AsyncIterator<any, any, any>>
async iterator yielding the updated model on each store change
registerAsyncIteratorQuery()
registerAsyncIteratorQuery(
model,plural,query,context):Promise<AsyncIterator<any,any,any>>
Defined in: graphql/src/graphql.service.ts:1534
Create an async iterator that streams query results, updating when store events occur
Parameters
model
ModelDefinition<any>
model class to query
plural
string
plural name used as the iterator prefix key
query
string
WebdaQL query string
context
any
web context for permission checks
Returns
Promise<AsyncIterator<any, any, any>>
async iterator yielding updated query results on store changes
removeAllListeners()
removeAllListeners<
Key>(eventName?):this
Defined in: core/lib/events/asynceventemitter.d.ts:122
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
eventName?
Key
the event name
Returns
this
this for chaining
See
EventEmitter.removeAllListeners
Inherited from
DomainService.removeAllListeners
removeListener()
removeListener<
Key>(eventName,listener):this
Defined in: core/lib/events/asynceventemitter.d.ts:109
Type Parameters
Key
Key extends "Store.WebNotFound"
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.removeListener
Inherited from
DomainService.removeListener
renamedField()
protectedrenamedField(config,key,name,input?):any
Defined in: graphql/src/graphql.service.ts:493
A field renamed from its JSON key reads that key (output), and carries it to be put back on inputs (restoreInputKeys)
Parameters
config
any
the field config
key
string
the JSON key
name
string
the GraphQL name
input?
boolean
an input type field
Returns
any
the field config
reserveName()
reserveName(
name,shape):void
Defined in: graphql/src/graphql.service.ts:375
Reserve a type name for a type built later (its entry gets the type once built)
Parameters
name
string
type name
shape
string
identity of the reserving type
Returns
void
Throws
Error when the name is already taken by another shape
resolve()
resolve():
GraphQLService<T>
Defined in: graphql/src/graphql.service.ts:845
Set up WebSocket server for GraphQL subscriptions and register upgrade handler
Returns
GraphQLService<T>
this instance for chaining
Overrides
DomainService.resolve
resolveUpdateKey()
protectedresolveUpdateKey(input,pkFields,params):any
Defined in: core/lib/services/domainservice.service.d.ts:230
Resolve the primary key of an update or patch: the URL parameters win over the body, and a body carrying another key is refused, so an update can never be redirected to another object
Parameters
input
any
the sanitized input, its primary-key fields are removed
pkFields
string[] | undefined
the primary-key fields
params
Record<string, any>
the URL parameters
Returns
any
the primary key
Throws
BadRequest when the body key differs from the URL key
Inherited from
DomainService.resolveUpdateKey
runOperation()
runOperation(
id,op,input,context):Promise<unknown>
Defined in: graphql/src/graphql.service.ts:1385
Run an operation for a query or mutation field
Parameters
id
string
operation id
op
OperationDefinition
operation
input
unknown
operation input
context
WebContext
the GraphQL request context
Returns
Promise<unknown>
the field value
schemaRoute()
schemaRoute(
ctx):Promise<void>
Defined in: graphql/src/graphql.service.ts:1836
Serve the GraphQL schema as text or the GraphiQL IDE as HTML
Parameters
ctx
WebContext<any>
incoming web context
Returns
Promise<void>
setMaxListeners()
setMaxListeners(
n):this
Defined in: core/lib/events/asynceventemitter.d.ts:88
Parameters
n
number
Returns
this
Inherited from
DomainService.setMaxListeners
stop()
stop():
Promise<void>
Defined in: core/lib/services/service.d.ts:86
Shutdown the current service if action need to be taken
Returns
Promise<void>
Inherited from
DomainService.stop
subscribeOperation()
subscribeOperation(
id,op,input,context):Promise<AsyncIterableIterator<unknown,any,any>>
Defined in: graphql/src/graphql.service.ts:1408
Start a server-streaming operation for a subscription field
Parameters
id
string
operation id
op
OperationDefinition
operation
input
unknown
operation input
context
WebContext
the GraphQL request context
Returns
Promise<AsyncIterableIterator<unknown, any, any>>
the chunks; leaving the subscription cancels the operation
toJSON()
toJSON():
string
Defined in: core/lib/services/service.d.ts:191
Prevent service to be serialized
Returns
string
the result
Inherited from
DomainService.toJSON
toString()
toString():
string
Defined in: core/lib/services/service.d.ts:91
Return service representation
Returns
string
the result
Inherited from
DomainService.toString
transformName()
transformName(
name):string
Defined in: core/lib/services/domainservice.service.d.ts:176
Return the model name for this service
Parameters
name
string
the name to use
Returns
string
the result string
See
https://blog.boot.dev/clean-code/casings-in-coding/#:~:text=%F0%9F%94%97%20Camel%20Case,Go
Inherited from
DomainService.transformName
withTotal()
protectedwithTotal(model,query,context):Promise<QueryResultWithTotal>
Defined in: graphql/src/graphql.service.ts:1495
Query a model as the caller and attach the lazy total of the query, resolved by the total field
Parameters
model
any
the model class
query
string
the query, with its relation condition
context
any
the caller context
Returns
Promise<QueryResultWithTotal>
the readable results
createConfiguration()
staticcreateConfiguration(params?):GraphQLParameters
Defined in: graphql/src/graphql.service.ts:322
Parameters with their defaults (the core builds a service configuration through this, not loadParameters)
Parameters
params?
any = {}
raw partial configuration
Returns
initialized GraphQLParameters
Overrides
DomainService.createConfiguration