Package Exports
- @n1ru4l/graphql-live-query-patch
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@n1ru4l/graphql-live-query-patch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@n1ru4l/graphql-live-query-patch
Make your live query payload smaller with json patches.
If you have big live query operations you might opt into only sending JSON patches to your clients. This requires the server to always store the latest execution result. When a new execution result is published a JSON patch is generated by diffing those execution results. The resulting patch operations are then sent to the client where they are applied to the initial execution result.
For example usage check out the todo-example client & server code.
Install Instructions
yarn add -E @n1ru4l/graphql-live-query-patchAPI
createLiveQueryPatchDeflator
import { execute } from "graphql";
import { createLiveQueryPatchDeflator } from "@n1ru4l/graphql-live-query-patch";
import { schema } from "./schema";
execute({
schema,
operationDocument: parse(/* GraphQL */ `
query todosQuery @live {
todos {
id
content
isComplete
}
}
`),
rootValue: rootValue,
contextValue: {},
variableValues: null,
operationName: "todosQuery",
}).then(async (result) => {
if (isAsyncIterable(result)) {
for (const value of createLiveQueryPatchDeflator(result)) {
console.log(value);
}
}
});applyLiveQueryPatchDeflator
Convenience wrapper for applying createLiveQueryPatchDeflator on the execute return value.
import { execute } from "graphql";
import { applyLiveQueryPatchDeflator } from "@n1ru4l/graphql-live-query-patch";
import { schema } from "./schema";
const result = applyLiveQueryPatchDeflator(
execute({
schema,
operationDocument: parse(/* GraphQL */ `
query todosQuery @live {
todos {
id
content
isComplete
}
}
`),
rootValue: rootValue,
contextValue: {},
variableValues: null,
operationName: "todosQuery",
})
);createLiveQueryPatchInflator
Inflate the execution result on the client side.
import { createLiveQueryPatchInflator } from "@n1ru4l/graphql-live-query-patch";
const asyncIterable = createLiveQueryPatchInflator(
networkLayer.execute({
operation: /* GraphQL */ `
query todosQuery @live {
todos {
id
content
isComplete
}
}
`,
})
);