Add explicit CRDT edit contracts and structured query values
This commit is contained in:
+18
-7
@@ -1,3 +1,4 @@
|
||||
import { structuredQueryTypes, comparableValue } from "./structured.js";
|
||||
import {
|
||||
GraphQLBoolean,
|
||||
GraphQLString,
|
||||
@@ -132,7 +133,7 @@ export function querySchema(
|
||||
throw new QueryCompileError("QUERY_TYPE", "Only scalar/optional scalar query fields are supported");
|
||||
return queryScalars[type.name];
|
||||
};
|
||||
const comparison = (type: ValueType) => {
|
||||
const scalarComparison = (type: ValueType) => {
|
||||
const base = type.kind === "optional" ? type.value : type;
|
||||
const value = scalar(base);
|
||||
const key = String(value);
|
||||
@@ -149,8 +150,21 @@ export function querySchema(
|
||||
}
|
||||
return result;
|
||||
};
|
||||
const structured = structuredQueryTypes(scalar, scalarComparison, direction);
|
||||
const comparison = (type: ValueType) => structured.input(type) as GraphQLInputObjectType;
|
||||
const relational = relationalSchema(
|
||||
{ contracts, target, name, scalar, comparison, scalarTypes, direction, cursor: cursorScalar, pageInfo },
|
||||
{
|
||||
contracts,
|
||||
target,
|
||||
name,
|
||||
scalar,
|
||||
comparison,
|
||||
valueOrder: (type) => structured.input(type, true),
|
||||
scalarTypes,
|
||||
direction,
|
||||
cursor: cursorScalar,
|
||||
pageInfo,
|
||||
},
|
||||
document,
|
||||
);
|
||||
relational.discover(root.interface);
|
||||
@@ -162,7 +176,7 @@ export function querySchema(
|
||||
for (const member of contract(id).members) {
|
||||
if (member.kind !== "value" || !member.queryRead) continue;
|
||||
const t = member.valueType.kind === "optional" ? member.valueType.value : member.valueType;
|
||||
if (t.kind === "scalar" && t.name !== "bytes") fields[member.displayName] = { type: direction };
|
||||
if (comparableValue(t, true)) fields[member.displayName] = { type: structured.input(t, true) };
|
||||
}
|
||||
if (Object.keys(fields).length === 0) return undefined;
|
||||
result = new GraphQLInputObjectType({ name: `${name(id)}Order`, fields });
|
||||
@@ -190,10 +204,7 @@ export function querySchema(
|
||||
if (!/^[_A-Za-z][_0-9A-Za-z]*$/.test(member.displayName) || member.displayName.startsWith("_"))
|
||||
throw new QueryCompileError("QUERY_SCHEMA_NAME", `Unsupported query field name ${member.displayName}`);
|
||||
if (member.kind === "value") {
|
||||
const type = scalar(member.valueType);
|
||||
fields[member.displayName] = {
|
||||
type: member.valueType.kind === "optional" ? type : new GraphQLNonNull(type),
|
||||
};
|
||||
fields[member.displayName] = { type: structured.output(member.valueType) };
|
||||
} else {
|
||||
const targetId = target(member),
|
||||
node = object(targetId);
|
||||
|
||||
Reference in New Issue
Block a user