GraphQLService
Class: GraphQLService<T>
Defined in: graphql/src/graphql.service.ts:302
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
Create a new Service instance
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:50
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:326
Application instance
Overrides
DomainService.app
handler?
optionalhandler?:Handler
Defined in: graphql/src/graphql.service.ts:310
Handler
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:346
The CRUD fields generateSchema() gave to each exposed model, by model id
modelListeners
modelListeners:
any
Defined in: graphql/src/graphql.service.ts:338
Model listeners
modelsMap
modelsMap:
object
Defined in: graphql/src/graphql.service.ts:314
Models map
Index Signature
[key: string]: GraphQLObjectType<any, any, any>
name
readonlyname:string
Defined in: core/lib/services/iservice.d.ts:27
Name
Inherited from
DomainService.name
namedTypes
namedTypes:
Map<string, {shape:string;type?:GraphQLType; }>
Defined in: graphql/src/graphql.service.ts:322
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:342
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:31
Parameters
Inherited from
DomainService.parameters
queryTotalType?
protectedoptionalqueryTotalType?:GraphQLObjectType<any,any,any>
Defined in: graphql/src/graphql.service.ts:318
Type of the total field of the query results (reset by generateSchema)
schema
schema:
GraphQLSchema
Defined in: graphql/src/graphql.service.ts:306
Schema
wsHandler
wsHandler:
Server
Defined in: graphql/src/graphql.service.ts:334
WS handler
wss
wss:
WebSocketServer
Defined in: graphql/src/graphql.service.ts:330
Wss
filterConfiguration?
staticoptionalfilterConfiguration?: (params) =>any
Defined in: core/lib/services/iservice.d.ts:39
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:181
Schemas
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.description
description:
string
searchRequest.properties.query.type
type:
string
searchRequest.properties.query.x-webda-sanitize
x-webda-sanitize:
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:224
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:334
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,pkFields?,requireKey?):string
Defined in: core/lib/services/domainservice.service.d.ts:357
Register the input schema of an instance action operation: the primary key and action parameters
The key fields come first in x-webda-arguments: modelAction loads the object with them 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)
pkFields?
string[]
implicit primary key fields
requireKey?
boolean
whether the caller must supply the parent key (login MFA uses the session)
Returns
string
the registered schema name, <modelKey>.<name>.request
Throws
Error when an action parameter conflicts with a primary key field
Inherited from
DomainService.actionRequestSchema
addBehaviorOperations()
addBehaviorOperations(
model,Metadata,name):void
Defined in: core/lib/services/domainservice.service.d.ts:384
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:87
Add listener
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:1424
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:1706
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
assertNoStatement()
protectedassertNoStatement(validator):void
Defined in: graphql/src/graphql.service.ts:1691
Refuse a parsed query that is not a filter: DELETE, UPDATE, and a SELECT field list. The REST, gRPC and MCP Query operations project their results on a field list; here the selection set already chooses the fields
Parameters
validator
QueryValidator
the parsed client query
Returns
void
Throws
WebdaError.BadRequest 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
callModelOperation()
callModelOperation(
model,method,context,input?,key?):Promise<{result:unknown; } |undefined>
Defined in: graphql/src/graphql.service.ts:1386
Run a model mutation as the operation a DomainService registered for it (<Model>.Create, .Update,
.Delete), so GraphQL does exactly what the other transports do: the same permission checks in the same order,
the input sanitized and validated against the model schema, the same events (audit) and transaction
A model no DomainService exposes has no such operation: the caller then applies the mutation itself.
Parameters
model
any
model class
method
"modelCreate" | "modelUpdate" | "modelDelete"
the DomainService method of the operation
context
WebContext
the GraphQL request context
input?
unknown
the model input, as received
key?
unknown
the primary key, for an update or a delete
Returns
Promise<{ result: unknown; } | undefined>
the operation result, undefined when the model has no such operation
Throws
GraphQLError the error of the operation (BAD_USER_INPUT with the validation details, NOT_FOUND, PERMISSION_DENIED, CONFLICT)
checkParent()
protectedcheckParent(model,parentId,context):Promise<void>
Defined in: core/lib/services/domainservice.service.d.ts:261
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:228
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:279
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:935
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:2002
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:213
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:2095
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:1001
Generate GraphQL schema
Returns
void
getCapabilities()
getCapabilities():
Record<string,any>
Defined in: core/lib/services/iservice.d.ts:72
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:1610
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:594
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:549
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:574
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:1932
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:432
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:371
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:91
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:246
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.
This is the body callOperation validated against the operation input schema and handed to the authorizers:
HTML-sanitized, except for the attributes the model tags @sanitize none, html or markdown. Do not override
this method to read the raw body (context.getInput({ raw: true })): the model would then receive values that
were never validated. Tag the attributes instead.
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:218
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:1626
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:516
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:2027
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:1904
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:322
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:1964
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:370
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:365
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:151
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:854
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:880
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:352
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:236
Log operation
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:343
Action on a model
An instance action receives the primary key fields 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:391
Load the parent by its resolved key, check the dotted behavior permission, and forward the typed arguments. Login MFA keeps its own pending-session lifecycle checks.
Parameters
args
...any[]
parent key fields followed by method parameters in declaration order
Returns
Promise<any>
the behavior method's return value
Inherited from
DomainService.modelBehaviorAction
modelCreate()
modelCreate():
Promise<Model>
Defined in: core/lib/services/domainservice.service.d.ts:253
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:297
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:292
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:314
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:307
Query models
With a field list (SELECT title, owner.name WHERE ...) each result only holds the selected fields and the
primary key, see queryModelWithPermissions.
Parameters
query
string
the query string: a WebdaQL filter, optionally with a SELECT field list
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:286
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:392
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:127
Perform off
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:111
Perform on
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:103
Perform once
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:1487
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:1536
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
operationSchemaName()
protectedoperationSchemaName(method,side):string
Defined in: core/lib/services/service.d.ts:191
Schema of an operation side: <service name>.<method>.<side> when the application knows it, else the one the
build writes, <class>.<method>.<side>, for the class or its nearest ancestor that has it (a service configured
under another name than its class)
Parameters
method
string
the method name
side
"input" | "output"
input or output
Returns
string
the schema name
Inherited from
DomainService.operationSchemaName
parseFilter()
parseFilter(
filter?,model?):Promise<PartialValidator|undefined>
Defined in: graphql/src/graphql.service.ts:826
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
model?
any
the model of the linked objects, for the sanitization of the literals
Returns
Promise<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:1660
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:1642
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
readRequest()
protectedreadRequest(ctx):Promise<any>
Defined in: graphql/src/graphql.service.ts:2065
Read a GraphQL request as the client sent it
It is not sanitized here: sanitizing the document would change its literals before they are parsed, and the
variables are not all texts of the same kind. Every argument is sanitized once graphql-js has coerced it (see
sanitizeFieldArguments), a model input with the modes of its model, an operation input from its schema.
Parameters
ctx
WebContext<any>
incoming web context
Returns
Promise<any>
the parsed body, undefined when there is none or it is not JSON
registerAsyncEventIterator()
registerAsyncEventIterator(
model,uuid,events,context,identifier):Promise<AsyncIterator<any,any,any>>
Defined in: graphql/src/graphql.service.ts:1848
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:1797
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:1730
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:134
Remove all listeners
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:119
Remove listener
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:532
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:414
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:953
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:271
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:1558
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:2037
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:95
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:1581
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:200
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:212
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:1672
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:361
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