@graphql-live/client
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,3 +1,4 @@ | ||
import { ManagerOptions, SocketOptions } from "socket.io-client"; | ||
import { ExecutionResult } from "graphql"; | ||
import { ManagerOptions, SocketOptions } from "socket.io-client"; | ||
import { Operation as PatchOperation } from "fast-json-patch"; | ||
export declare type ClientOptions = { | ||
@@ -10,2 +11,3 @@ url?: string; | ||
observer: ResultObserver; | ||
latestResult: ExecutionResult; | ||
execute(): void; | ||
@@ -25,3 +27,3 @@ }; | ||
id: number; | ||
result: ExecutionResult; | ||
patch: Array<PatchOperation>; | ||
isFinal?: boolean; | ||
@@ -28,0 +30,0 @@ }; |
@@ -11,2 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { io } from "socket.io-client"; | ||
import { applyPatch } from "fast-json-patch"; | ||
export function createClient({ url, context, socketOptions } = {}) { | ||
@@ -27,7 +28,9 @@ const socket = url ? io(url, socketOptions) : io(socketOptions); | ||
}; | ||
const onOperationResult = ({ id, result, isFinal }) => { | ||
const onOperationResult = ({ id, patch, isFinal }) => { | ||
const record = operations.get(id); | ||
if (!record) | ||
return; | ||
record.observer.next(result); | ||
const previousResult = record.latestResult; | ||
record.latestResult = applyPatch(previousResult, patch).newDocument; | ||
record.observer.next(record.latestResult); | ||
if (isFinal) { | ||
@@ -51,2 +54,3 @@ operations.delete(id); | ||
observer, | ||
latestResult: {}, | ||
execute() { | ||
@@ -53,0 +57,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@graphql-live/client", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "The client part of the GraphQLive package", | ||
@@ -37,2 +37,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"fast-json-patch": "^3.0.0-1", | ||
"graphql": "^15.5.0", | ||
@@ -39,0 +40,0 @@ "socket.io-client": "^4.0.0" |
@@ -0,3 +1,4 @@ | ||
import { io, ManagerOptions, SocketOptions } from "socket.io-client"; | ||
import { ExecutionResult } from "graphql"; | ||
import { io, ManagerOptions, SocketOptions } from "socket.io-client"; | ||
import { applyPatch, Operation as PatchOperation } from "fast-json-patch"; | ||
@@ -12,2 +13,3 @@ export type ClientOptions = { | ||
observer: ResultObserver; | ||
latestResult: ExecutionResult; | ||
execute(): void; | ||
@@ -30,3 +32,3 @@ }; | ||
id: number; | ||
result: ExecutionResult; | ||
patch: Array<PatchOperation>; | ||
isFinal?: boolean; | ||
@@ -62,6 +64,8 @@ }; | ||
const onOperationResult = ({ id, result, isFinal }: ResultPayload) => { | ||
const onOperationResult = ({ id, patch, isFinal }: ResultPayload) => { | ||
const record = operations.get(id); | ||
if (!record) return; | ||
record.observer.next(result); | ||
const previousResult = record.latestResult; | ||
record.latestResult = applyPatch(previousResult, patch).newDocument; | ||
record.observer.next(record.latestResult); | ||
if (isFinal) { | ||
@@ -88,2 +92,3 @@ operations.delete(id); | ||
observer, | ||
latestResult: {}, | ||
async execute() { | ||
@@ -90,0 +95,0 @@ const payload: OperationPayload = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157866
274
3
+ Addedfast-json-patch@^3.0.0-1
+ Addedfast-json-patch@3.1.1(transitive)