diff --git a/package.json b/package.json index 6e493ada..a4ec51f9 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "private": true, "dependencies": { "@n1ru4l/graphql-live-query": "0.7.1", - "@n1ru4l/graphql-live-query-patch": "0.3.1", - "@n1ru4l/in-memory-live-query-store": "0.6.5", + "@n1ru4l/graphql-live-query-patch-json-patch": "0.3.3", + "@n1ru4l/in-memory-live-query-store": "0.6.6", "@n1ru4l/socket-io-graphql-server": "0.9.2", "@tinyhttp/app": "1.3.15", "@types/better-sqlite3": "5.4.3", diff --git a/server/main.ts b/server/main.ts index 5dae0c45..e1ac0ce7 100644 --- a/server/main.ts +++ b/server/main.ts @@ -6,7 +6,7 @@ import { Server, Socket } from "socket.io"; import serveStatic from "serve-static"; import { registerSocketIOGraphQLServer } from "@n1ru4l/socket-io-graphql-server"; import { InMemoryLiveQueryStore } from "@n1ru4l/in-memory-live-query-store"; -import { createApplyLiveQueryPatchGenerator } from "@n1ru4l/graphql-live-query-patch"; +import { applyLiveQueryJSONPatchGenerator } from "@n1ru4l/graphql-live-query-patch-json-patch"; import Database from "better-sqlite3"; import { schema } from "./schema"; import type { ApplicationContext } from "./ApplicationContext"; @@ -72,7 +72,7 @@ const graphQLServerLayer = registerSocketIOGraphQLServer({ socketServer, getParameter: () => ({ execute: (...args) => - createApplyLiveQueryPatchGenerator()(liveQueryStore.execute(...args)), + applyLiveQueryJSONPatchGenerator(liveQueryStore.execute(...args)), graphQLExecutionParameter: { schema, contextValue: { diff --git a/src/__generated__/types.ts b/src/__generated__/types.ts index 901da090..b2903efd 100644 --- a/src/__generated__/types.ts +++ b/src/__generated__/types.ts @@ -17,27 +17,6 @@ export type Scalars = { Float: number; }; -export type Query = { - __typename?: "Query"; - characterEditor?: Maybe; - character?: Maybe; -}; - -export type QueryCharacterEditorArgs = { - editHash: Scalars["ID"]; -}; - -export type QueryCharacterArgs = { - id: Scalars["ID"]; -}; - -export type CharacterEditor = CharacterEditorView | Error; - -export type CharacterEditorView = { - __typename?: "CharacterEditorView"; - character: Character; -}; - export type Character = { __typename?: "Character"; id: Scalars["ID"]; @@ -53,24 +32,11 @@ export type Character = { maximumFatePoints: Scalars["Int"]; }; -export type Error = { - __typename?: "Error"; - reason: Scalars["String"]; -}; - -export type Mutation = { - __typename?: "Mutation"; - updateCharacter?: Maybe; - createCharacter: CreateCharacterResult; -}; - -export type MutationUpdateCharacterArgs = { - input: UpdateCharacterInput; -}; +export type CharacterEditor = CharacterEditorView | Error; -export type UpdateCharacterInput = { - editHash: Scalars["String"]; - updates: CharacterUpdateFields; +export type CharacterEditorView = { + __typename?: "CharacterEditorView"; + character: Character; }; export type CharacterUpdateFields = { @@ -92,3 +58,37 @@ export type CreateCharacterSuccess = { __typename?: "CreateCharacterSuccess"; editHash: Scalars["String"]; }; + +export type Error = { + __typename?: "Error"; + reason: Scalars["String"]; +}; + +export type Mutation = { + __typename?: "Mutation"; + updateCharacter?: Maybe; + createCharacter: CreateCharacterResult; +}; + +export type MutationUpdateCharacterArgs = { + input: UpdateCharacterInput; +}; + +export type Query = { + __typename?: "Query"; + characterEditor?: Maybe; + character?: Maybe; +}; + +export type QueryCharacterEditorArgs = { + editHash: Scalars["ID"]; +}; + +export type QueryCharacterArgs = { + id: Scalars["ID"]; +}; + +export type UpdateCharacterInput = { + editHash: Scalars["String"]; + updates: CharacterUpdateFields; +}; diff --git a/src/createUrqlClient.ts b/src/createUrqlClient.ts index 9a0b874a..3fd614df 100644 --- a/src/createUrqlClient.ts +++ b/src/createUrqlClient.ts @@ -7,7 +7,7 @@ import { } from "urql"; import { io } from "socket.io-client"; import { createSocketIOGraphQLClient } from "@n1ru4l/socket-io-graphql-client"; -import { createApplyLiveQueryPatch } from "@n1ru4l/graphql-live-query-patch"; +import { applyLiveQueryJSONPatch } from "@n1ru4l/graphql-live-query-patch-json-patch"; import { applyAsyncIterableIteratorToSink } from "@n1ru4l/push-pull-async-iterable-iterator"; const APP_VERSION = @@ -28,7 +28,7 @@ export const createUrqlClient = () => { forwardSubscription: ({ query: operation, variables }) => ({ subscribe: (sink) => ({ unsubscribe: applyAsyncIterableIteratorToSink( - createApplyLiveQueryPatch()( + applyLiveQueryJSONPatch( networkInterface.execute({ operation, variables, diff --git a/tsconfig.json b/tsconfig.json index 9d379a3c..1b156772 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "ES2018", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, diff --git a/yarn.lock b/yarn.lock index b3ab4fbe..4ee6e621 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1583,6 +1583,13 @@ camel-case "4.1.2" tslib "~2.2.0" +"@graphql-tools/utils@^8.0.0": + version "8.0.1" + resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-8.0.1.tgz#bf09e8d6d17c4a0830f0fbf2c69dd725de19058c" + integrity sha512-gjQk6sht4b0/hcG+QEVxfMyO8bn5tuU1nIOVhQ4whgFaUmrnb3hx2mwzz1EJzfIOAuHKE8tY0lu6jt3bGTD4yg== + dependencies: + tslib "~2.3.0" + "@graphql-tools/wrap@^7.0.4": version "7.0.8" resolved "https://registry.yarnpkg.com/@graphql-tools/wrap/-/wrap-7.0.8.tgz#ad41e487135ca3ea1ae0ea04bb3f596177fb4f50" @@ -1807,10 +1814,18 @@ resolved "https://registry.yarnpkg.com/@microsoft/fetch-event-source/-/fetch-event-source-2.0.1.tgz#9ceecc94b49fbaa15666e38ae8587f64acce007d" integrity sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA== -"@n1ru4l/graphql-live-query-patch@0.3.1": - version "0.3.1" - resolved "https://registry.yarnpkg.com/@n1ru4l/graphql-live-query-patch/-/graphql-live-query-patch-0.3.1.tgz#b6ce6f7b9855b9c5984958b81a5cda54040aa598" - integrity sha512-c9m7Q1jVZ4OAIfnBIymjOnsMJpLcwyaP7RoTzSefJon9I2HukXtpHvwrgdc/Z8mFWPprMWggu3vEwwtIxrFnSg== +"@n1ru4l/graphql-live-query-patch-json-patch@0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@n1ru4l/graphql-live-query-patch-json-patch/-/graphql-live-query-patch-json-patch-0.3.3.tgz#7cf60ee7e34c5d5b0eb536d0b5c3e64ecdb97065" + integrity sha512-NAYpFyxYlWcPJgc5W7b3t9jXYSqvxKKH/xPZdUn+KTKbNbbcQw/ZpEipr5r0/shsvuSxiWNi7vvjfPBZX6oOXA== + dependencies: + "@n1ru4l/graphql-live-query-patch" "^0.3.2" + fast-json-patch "3.0.0-1" + +"@n1ru4l/graphql-live-query-patch@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@n1ru4l/graphql-live-query-patch/-/graphql-live-query-patch-0.3.2.tgz#c268c7b38e128ff117db12176514826fc9b50007" + integrity sha512-ydXF1lX30JXb6g8BjDehkp0UFNDii4/Z9yXjBxySleE3ZB3MzYSzL8U59mh6yUxd6CcuZkNwuxuP00T4y7/Sfg== dependencies: fast-json-patch "3.0.0-1" @@ -1819,16 +1834,16 @@ resolved "https://registry.yarnpkg.com/@n1ru4l/graphql-live-query/-/graphql-live-query-0.7.1.tgz#c020d017c3ed6bcfdde49a7106ba035e4d0774f5" integrity sha512-5kJPe2FkPNsCGu9tocKIzUSNO986qAqdnbk8hIFqWlpVPBAmEAOYb1mr6PA18FYAlu7ojWm9Hm13k29aj2GGlQ== -"@n1ru4l/in-memory-live-query-store@0.6.5": - version "0.6.5" - resolved "https://registry.yarnpkg.com/@n1ru4l/in-memory-live-query-store/-/in-memory-live-query-store-0.6.5.tgz#17dbd198b70da34ea7d8b05098945bbd3b2dbecc" - integrity sha512-Yj9ova+t3TKuD5HFkqEBnjI1apNSEXq0JDqH41xz6ArWDLVY9e9kZMQBmIXe2iTeaKtkYOhcmrw2kdjITZaiqw== +"@n1ru4l/in-memory-live-query-store@0.6.6": + version "0.6.6" + resolved "https://registry.yarnpkg.com/@n1ru4l/in-memory-live-query-store/-/in-memory-live-query-store-0.6.6.tgz#57f4b7e4219c062a82da6b4e6434f0bda5284497" + integrity sha512-91GdnWsnSq2ZI4C0vJlzedXPjWNxz71RP+870RJjRoHmsco5vyDs6W3y9aCUy02HkGwhdJNuf6qSylBA8oDKqQ== dependencies: - "@graphql-tools/utils" "^7.7.1" + "@graphql-tools/utils" "^8.0.0" "@n1ru4l/graphql-live-query" "0.7.1" - "@n1ru4l/push-pull-async-iterable-iterator" "^2.1.4" + "@n1ru4l/push-pull-async-iterable-iterator" "^3.0.0" -"@n1ru4l/push-pull-async-iterable-iterator@3.0.0": +"@n1ru4l/push-pull-async-iterable-iterator@3.0.0", "@n1ru4l/push-pull-async-iterable-iterator@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@n1ru4l/push-pull-async-iterable-iterator/-/push-pull-async-iterable-iterator-3.0.0.tgz#22dc34094c2de5f21b9a798d0ffab16b45de0eb7" integrity sha512-gwoIwo/Dt1GOI+lbcG1G7IeRM2K+Fo0op3OGyFJ4tXUCf2a3Q8lUCm81aoevrXC0nu4gbAXeOWy7wWxjpSvZUw==