|
@@ -91,27 +91,20 @@ export function characterHandlers(_io, socket) {
|
|
|
idValidator: characterSchema.shape.id.parse
|
|
idValidator: characterSchema.shape.id.parse
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function typenameMutator(rawResult) {
|
|
|
|
|
- if (_isPlainObject(rawResult) && _has(rawResult, "id")) {
|
|
|
|
|
- _set(rawResult, "__typename", "character")
|
|
|
|
|
- } else if (_isArray(rawResult)) {
|
|
|
|
|
- _forEach(rawResult, (entry) =>
|
|
|
|
|
- _set(entry, "__typename", "character")
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return rawResult
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- let mutator
|
|
|
|
|
|
|
+ const mutators = [
|
|
|
|
|
+ stringifyIds,
|
|
|
|
|
+ injectTypename("character"),
|
|
|
|
|
+ injectEntityId("character")
|
|
|
|
|
+ ]
|
|
|
|
|
|
|
|
if (_has(options, "mutator")) {
|
|
if (_has(options, "mutator")) {
|
|
|
- mutator = _flow([options.mutator, typenameMutator])
|
|
|
|
|
- _unset(options, "mutator")
|
|
|
|
|
- } else {
|
|
|
|
|
- mutator = typenameMutator
|
|
|
|
|
|
|
+ mutators.unshift(options.mutator)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return await executeQuery({ ...defaultOptions, ...options, mutator })
|
|
|
|
|
|
|
+ return await executeQuery({
|
|
|
|
|
+ ...defaultOptions,
|
|
|
|
|
+ ...options,
|
|
|
|
|
+ mutator: _flow(mutators)
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|