Implement main-thread Camino sessions and synchronous CRDT editing
This commit is contained in:
@@ -126,8 +126,29 @@ export function querySchema(
|
||||
);
|
||||
return views[0]!.interfaceRevisionId;
|
||||
};
|
||||
const variants = new Map<string, GraphQLScalarType>();
|
||||
const scalar = (type: ValueType): GraphQLOutputType & GraphQLInputType => {
|
||||
if (type.kind === "optional") return scalar(type.value);
|
||||
if (type.kind === "variant") {
|
||||
const name = `QxVariant_${createHash("sha256").update(JSON.stringify(type)).digest("hex").slice(0, 16)}`;
|
||||
let result = variants.get(name);
|
||||
if (!result) {
|
||||
result = new GraphQLScalarType({
|
||||
name,
|
||||
description: "Whole checked Camino variant value. Branch selection and predicates are not supported.",
|
||||
serialize: (value) => value,
|
||||
parseValue() {
|
||||
throw new QueryCompileError("QUERY_TYPE", "Variant query inputs are not supported");
|
||||
},
|
||||
parseLiteral() {
|
||||
throw new QueryCompileError("QUERY_TYPE", "Variant query inputs are not supported");
|
||||
},
|
||||
});
|
||||
variants.set(name, result);
|
||||
scalarTypes.set(name, type);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (type.kind !== "scalar")
|
||||
throw new QueryCompileError("QUERY_TYPE", "Only scalar/optional scalar query fields are supported");
|
||||
return queryScalars[type.name];
|
||||
|
||||
Reference in New Issue
Block a user