diff --git a/404.html b/404.html index 1217bf1..31f433f 100644 --- a/404.html +++ b/404.html @@ -4,7 +4,7 @@ GraphQL Client - + diff --git a/assets/js/79f7b534.958508a4.js b/assets/js/79f7b534.cf2fc73a.js similarity index 86% rename from assets/js/79f7b534.958508a4.js rename to assets/js/79f7b534.cf2fc73a.js index 22efc74..e7fba65 100644 --- a/assets/js/79f7b534.958508a4.js +++ b/assets/js/79f7b534.cf2fc73a.js @@ -1 +1 @@ -"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[456],{2029:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>u,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>r,toc:()=>l});var a=t(4848),s=t(8453);const i={title:"useMutation",sidebar_label:"useMutation"},o=void 0,r={id:"use-mutation",title:"useMutation",description:"useMutation(mutation, config?)",source:"@site/docs/use-mutation.md",sourceDirName:".",slug:"/use-mutation",permalink:"/graphql-client/use-mutation",draft:!1,unlisted:!1,editUrl:"https://github.com/swan-io/graphql-client/edit/main/docs/docs/use-mutation.md",tags:[],version:"current",frontMatter:{title:"useMutation",sidebar_label:"useMutation"},sidebar:"docs",previous:{title:"useDeferredQuery",permalink:"/graphql-client/use-deferred-query"},next:{title:"Client",permalink:"/graphql-client/client"}},u={},l=[{value:"useMutation(mutation, config?)",id:"usemutationmutation-config",level:2},{value:"Params",id:"params",level:3},{value:"Returns",id:"returns",level:3},{value:"Example",id:"example",level:2},{value:"Handling connections",id:"handling-connections",level:2}];function c(n){const e={code:"code",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...n.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e.h2,{id:"usemutationmutation-config",children:"useMutation(mutation, config?)"}),"\n",(0,a.jsx)(e.h3,{id:"params",children:"Params"}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"mutation"}),": your mutation document node"]}),"\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"config"}),":","\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"connectionUpdates"}),": configuration to prepend/append/remove edges from connections on mutation"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(e.h3,{id:"returns",children:"Returns"}),"\n",(0,a.jsxs)(e.p,{children:["This hook returns a tuple you can extract like a ",(0,a.jsx)(e.code,{children:"useState"}),":"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-ts",children:"const [commitMutation, mutationData] = useMutation(...)\n"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"commitMutation(variables)"}),": function commit the mutation, returns a ",(0,a.jsx)(e.code,{children:"Future>"})]}),"\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"mutationData"})," (",(0,a.jsx)(e.code,{children:"AsyncData>"}),"): the mutation data"]}),"\n"]}),"\n",(0,a.jsx)(e.h2,{id:"example",children:"Example"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-ts",children:'import { useMutation } from "@swan-io/graphql-client";\n// ...\n\nconst updateUsernameMutation = graphql(`\n mutation UpdateUsername($userId: ID!, $username: String!) {\n updateUsername(id: $userId, username: $username) {\n ... on UpdateUsernameSuccessPayload {\n user {\n id\n username\n avatar\n }\n }\n ... on InvalidUsernameRejection {\n message\n }\n }\n }\n`);\n\ntype Props = {\n userId: string;\n};\n\nconst UserPage = ({ userId }: Props) => {\n const [updateUsername, usernameUpdate] = useMutation(updateUsernameMutation);\n const [username, setUsername] = useState("");\n\n // ...\n const onSubmit = (event) => {\n event.preventDefault();\n updateUsername({ userId, username });\n };\n\n const isLoading = usernameUpdate.isLoading();\n\n return (\n
\n setUsername(event.target.value)}\n />\n\n \n \n );\n};\n'})}),"\n",(0,a.jsx)(e.h2,{id:"handling-connections",children:"Handling connections"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-ts",children:"useMutation(BlockUser, {\n connectionUpdates: [\n ({ data, append }) =>\n Option.fromNullable(data.blockUser).map(({ user }) =>\n append(blockedUsers, [user]),\n ),\n ({ data, prepend }) =>\n Option.fromNullable(data.blockUser).map(({ user }) =>\n prepend(lastBlockedUsers, [user]),\n ),\n ],\n});\n\nuseMutation(Unfriend, {\n connectionUpdates: [\n ({ variables, remove }) =>\n Option.fromNullable(data.unfriend).map(() =>\n remove(friends, [variables.id]),\n ),\n ],\n});\n"})})]})}function d(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,a.jsx)(e,{...n,children:(0,a.jsx)(c,{...n})}):c(n)}},8453:(n,e,t)=>{t.d(e,{R:()=>o,x:()=>r});var a=t(6540);const s={},i=a.createContext(s);function o(n){const e=a.useContext(i);return a.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:o(n.components),a.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file +"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[456],{2029:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>u,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>r,toc:()=>l});var a=t(4848),s=t(8453);const i={title:"useMutation",sidebar_label:"useMutation"},o=void 0,r={id:"use-mutation",title:"useMutation",description:"useMutation(mutation, config?)",source:"@site/docs/use-mutation.md",sourceDirName:".",slug:"/use-mutation",permalink:"/graphql-client/use-mutation",draft:!1,unlisted:!1,editUrl:"https://github.com/swan-io/graphql-client/edit/main/docs/docs/use-mutation.md",tags:[],version:"current",frontMatter:{title:"useMutation",sidebar_label:"useMutation"},sidebar:"docs",previous:{title:"useDeferredQuery",permalink:"/graphql-client/use-deferred-query"},next:{title:"Client",permalink:"/graphql-client/client"}},u={},l=[{value:"useMutation(mutation, config?)",id:"usemutationmutation-config",level:2},{value:"Params",id:"params",level:3},{value:"Returns",id:"returns",level:3},{value:"Example",id:"example",level:2},{value:"Handling connections",id:"handling-connections",level:2}];function c(n){const e={code:"code",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...n.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e.h2,{id:"usemutationmutation-config",children:"useMutation(mutation, config?)"}),"\n",(0,a.jsx)(e.h3,{id:"params",children:"Params"}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"mutation"}),": your mutation document node"]}),"\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"config"}),":","\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"connectionUpdates"}),": configuration to prepend/append/remove edges from connections on mutation"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(e.h3,{id:"returns",children:"Returns"}),"\n",(0,a.jsxs)(e.p,{children:["This hook returns a tuple you can extract like a ",(0,a.jsx)(e.code,{children:"useState"}),":"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-ts",children:"const [commitMutation, mutationData] = useMutation(...)\n"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"commitMutation(variables)"}),": function commit the mutation, returns a ",(0,a.jsx)(e.code,{children:"Future>"})]}),"\n",(0,a.jsxs)(e.li,{children:[(0,a.jsx)(e.code,{children:"mutationData"})," (",(0,a.jsx)(e.code,{children:"AsyncData>"}),"): the mutation data"]}),"\n"]}),"\n",(0,a.jsx)(e.h2,{id:"example",children:"Example"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-ts",children:'import { useMutation } from "@swan-io/graphql-client";\n// ...\n\nconst updateUsernameMutation = graphql(`\n mutation UpdateUsername($userId: ID!, $username: String!) {\n updateUsername(id: $userId, username: $username) {\n ... on UpdateUsernameSuccessPayload {\n user {\n id\n username\n avatar\n }\n }\n ... on InvalidUsernameRejection {\n message\n }\n }\n }\n`);\n\ntype Props = {\n userId: string;\n};\n\nconst UserPage = ({ userId }: Props) => {\n const [updateUsername, usernameUpdate] = useMutation(updateUsernameMutation);\n const [username, setUsername] = useState("");\n\n // ...\n const onSubmit = (event) => {\n event.preventDefault();\n updateUsername({ userId, username });\n };\n\n const isLoading = usernameUpdate.isLoading();\n\n return (\n
\n setUsername(event.target.value)}\n />\n\n \n \n );\n};\n'})}),"\n",(0,a.jsx)(e.h2,{id:"handling-connections",children:"Handling connections"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-ts",children:"useMutation(BlockUser, {\n connectionUpdates: [\n ({ data, append }) =>\n Option.fromNullable(data.blockUser).map(({ user }) =>\n append(blockedUsers, [user]),\n ),\n ({ data, prepend }) =>\n Option.fromNullable(data.blockUser).map(({ user }) =>\n prepend(lastBlockedUsers, [user]),\n ),\n ],\n});\n\nuseMutation(Unfriend, {\n connectionUpdates: [\n ({ data, variables, remove }) =>\n Option.fromNullable(data.unfriend).map(() =>\n remove(friends, [variables.id]),\n ),\n ],\n});\n"})})]})}function d(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,a.jsx)(e,{...n,children:(0,a.jsx)(c,{...n})}):c(n)}},8453:(n,e,t)=>{t.d(e,{R:()=>o,x:()=>r});var a=t(6540);const s={},i=a.createContext(s);function o(n){const e=a.useContext(i);return a.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:o(n.components),a.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.e8f1d640.js b/assets/js/runtime~main.e5c97046.js similarity index 98% rename from assets/js/runtime~main.e8f1d640.js rename to assets/js/runtime~main.e5c97046.js index 6aa72c1..c3163ea 100644 --- a/assets/js/runtime~main.e8f1d640.js +++ b/assets/js/runtime~main.e5c97046.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,r,a,o,n={},d={};function i(e){var t=d[e];if(void 0!==t)return t.exports;var r=d[e]={id:e,loaded:!1,exports:{}};return n[e].call(r.exports,r,r.exports,i),r.loaded=!0,r.exports}i.m=n,i.c=d,e=[],i.O=(t,r,a,o)=>{if(!r){var n=1/0;for(l=0;l=o)&&Object.keys(i.O).every((e=>i.O[e](r[f])))?r.splice(f--,1):(d=!1,o0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[r,a,o]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var o=Object.create(null);i.r(o);var n={};t=t||[null,r({}),r([]),r(r)];for(var d=2&a&&e;"object"==typeof d&&!~t.indexOf(d);d=r(d))Object.getOwnPropertyNames(d).forEach((t=>n[t]=()=>e[t]));return n.default=()=>e,i.d(o,n),o},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>"assets/js/"+({48:"a94703ab",98:"a7bd4aaa",113:"470aea15",165:"d73abe6d",401:"17896441",456:"79f7b534",546:"e8405da1",581:"935f2afb",585:"755cfc2e",634:"c4f5d8e4",647:"5e95c892",682:"138067e7",924:"d589d3a7",956:"6b495f58"}[e]||e)+"."+{48:"8b0ccadb",98:"fd305e17",113:"6ea4c2d0",165:"29c7a783",237:"7663bed8",401:"fd5a9d4d",456:"958508a4",546:"68558b10",581:"33f2a496",585:"a1a97e84",634:"12a7b096",647:"1dd55255",682:"b8bfd8a9",924:"26937052",956:"89d627ba"}[e]+".js",i.miniCssF=e=>{},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},o="docs:",i.l=(e,t,r,n)=>{if(a[e])a[e].push(t);else{var d,f;if(void 0!==r)for(var c=document.getElementsByTagName("script"),l=0;l{d.onerror=d.onload=null,clearTimeout(b);var o=a[e];if(delete a[e],d.parentNode&&d.parentNode.removeChild(d),o&&o.forEach((e=>e(r))),t)return t(r)},b=setTimeout(s.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=s.bind(null,d.onerror),d.onload=s.bind(null,d.onload),f&&document.head.appendChild(d)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.p="/graphql-client/",i.gca=function(e){return e={17896441:"401",a94703ab:"48",a7bd4aaa:"98","470aea15":"113",d73abe6d:"165","79f7b534":"456",e8405da1:"546","935f2afb":"581","755cfc2e":"585",c4f5d8e4:"634","5e95c892":"647","138067e7":"682",d589d3a7:"924","6b495f58":"956"}[e]||e,i.p+i.u(e)},(()=>{var e={354:0,869:0};i.f.j=(t,r)=>{var a=i.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(354|869)$/.test(t))e[t]=0;else{var o=new Promise(((r,o)=>a=e[t]=[r,o]));r.push(a[2]=o);var n=i.p+i.u(t),d=new Error;i.l(n,(r=>{if(i.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var o=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;d.message="Loading chunk "+t+" failed.\n("+o+": "+n+")",d.name="ChunkLoadError",d.type=o,d.request=n,a[1](d)}}),"chunk-"+t,t)}},i.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,n=r[0],d=r[1],f=r[2],c=0;if(n.some((t=>0!==e[t]))){for(a in d)i.o(d,a)&&(i.m[a]=d[a]);if(f)var l=f(i)}for(t&&t(r);c{"use strict";var e,t,r,a,o,n={},d={};function i(e){var t=d[e];if(void 0!==t)return t.exports;var r=d[e]={id:e,loaded:!1,exports:{}};return n[e].call(r.exports,r,r.exports,i),r.loaded=!0,r.exports}i.m=n,i.c=d,e=[],i.O=(t,r,a,o)=>{if(!r){var n=1/0;for(l=0;l=o)&&Object.keys(i.O).every((e=>i.O[e](r[f])))?r.splice(f--,1):(d=!1,o0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[r,a,o]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var o=Object.create(null);i.r(o);var n={};t=t||[null,r({}),r([]),r(r)];for(var d=2&a&&e;"object"==typeof d&&!~t.indexOf(d);d=r(d))Object.getOwnPropertyNames(d).forEach((t=>n[t]=()=>e[t]));return n.default=()=>e,i.d(o,n),o},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>"assets/js/"+({48:"a94703ab",98:"a7bd4aaa",113:"470aea15",165:"d73abe6d",401:"17896441",456:"79f7b534",546:"e8405da1",581:"935f2afb",585:"755cfc2e",634:"c4f5d8e4",647:"5e95c892",682:"138067e7",924:"d589d3a7",956:"6b495f58"}[e]||e)+"."+{48:"8b0ccadb",98:"fd305e17",113:"6ea4c2d0",165:"29c7a783",237:"7663bed8",401:"fd5a9d4d",456:"cf2fc73a",546:"68558b10",581:"33f2a496",585:"a1a97e84",634:"12a7b096",647:"1dd55255",682:"b8bfd8a9",924:"26937052",956:"89d627ba"}[e]+".js",i.miniCssF=e=>{},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},o="docs:",i.l=(e,t,r,n)=>{if(a[e])a[e].push(t);else{var d,f;if(void 0!==r)for(var c=document.getElementsByTagName("script"),l=0;l{d.onerror=d.onload=null,clearTimeout(b);var o=a[e];if(delete a[e],d.parentNode&&d.parentNode.removeChild(d),o&&o.forEach((e=>e(r))),t)return t(r)},b=setTimeout(s.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=s.bind(null,d.onerror),d.onload=s.bind(null,d.onload),f&&document.head.appendChild(d)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.p="/graphql-client/",i.gca=function(e){return e={17896441:"401",a94703ab:"48",a7bd4aaa:"98","470aea15":"113",d73abe6d:"165","79f7b534":"456",e8405da1:"546","935f2afb":"581","755cfc2e":"585",c4f5d8e4:"634","5e95c892":"647","138067e7":"682",d589d3a7:"924","6b495f58":"956"}[e]||e,i.p+i.u(e)},(()=>{var e={354:0,869:0};i.f.j=(t,r)=>{var a=i.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(354|869)$/.test(t))e[t]=0;else{var o=new Promise(((r,o)=>a=e[t]=[r,o]));r.push(a[2]=o);var n=i.p+i.u(t),d=new Error;i.l(n,(r=>{if(i.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var o=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;d.message="Loading chunk "+t+" failed.\n("+o+": "+n+")",d.name="ChunkLoadError",d.type=o,d.request=n,a[1](d)}}),"chunk-"+t,t)}},i.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,n=r[0],d=r[1],f=r[2],c=0;if(n.some((t=>0!==e[t]))){for(a in d)i.o(d,a)&&(i.m[a]=d[a]);if(f)var l=f(i)}for(t&&t(r);c Client | GraphQL Client - + diff --git a/getting-started/index.html b/getting-started/index.html index 9f29154..a739954 100644 --- a/getting-started/index.html +++ b/getting-started/index.html @@ -4,7 +4,7 @@ Getting started | GraphQL Client - + diff --git a/index.html b/index.html index 643a4f9..fe6bbad 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ GraphQL Client: A simple, typesafe GraphQL client for React | GraphQL Client - + diff --git a/pagination/index.html b/pagination/index.html index 98ea431..6a5a618 100644 --- a/pagination/index.html +++ b/pagination/index.html @@ -4,7 +4,7 @@ Pagination | GraphQL Client - + diff --git a/use-deferred-query/index.html b/use-deferred-query/index.html index f996826..c3d83e1 100644 --- a/use-deferred-query/index.html +++ b/use-deferred-query/index.html @@ -4,7 +4,7 @@ useDeferredQuery | GraphQL Client - + diff --git a/use-mutation/index.html b/use-mutation/index.html index 9d05c66..89bd41e 100644 --- a/use-mutation/index.html +++ b/use-mutation/index.html @@ -4,7 +4,7 @@ useMutation | GraphQL Client - + @@ -28,6 +28,6 @@

ReturnsExample

import { useMutation } from "@swan-io/graphql-client";
// ...

const updateUsernameMutation = graphql(`
mutation UpdateUsername($userId: ID!, $username: String!) {
updateUsername(id: $userId, username: $username) {
... on UpdateUsernameSuccessPayload {
user {
id
username
avatar
}
}
... on InvalidUsernameRejection {
message
}
}
}
`);

type Props = {
userId: string;
};

const UserPage = ({ userId }: Props) => {
const [updateUsername, usernameUpdate] = useMutation(updateUsernameMutation);
const [username, setUsername] = useState("");

// ...
const onSubmit = (event) => {
event.preventDefault();
updateUsername({ userId, username });
};

const isLoading = usernameUpdate.isLoading();

return (
<form onSubmit={onSubmit}>
<input
value={username}
readOnly={isLoading}
onChange={(event) => setUsername(event.target.value)}
/>

<button type="submit" readOnly={isLoading}>
Submit
</button>
</form>
);
};

Handling connections

-
useMutation(BlockUser, {
connectionUpdates: [
({ data, append }) =>
Option.fromNullable(data.blockUser).map(({ user }) =>
append(blockedUsers, [user]),
),
({ data, prepend }) =>
Option.fromNullable(data.blockUser).map(({ user }) =>
prepend(lastBlockedUsers, [user]),
),
],
});

useMutation(Unfriend, {
connectionUpdates: [
({ variables, remove }) =>
Option.fromNullable(data.unfriend).map(() =>
remove(friends, [variables.id]),
),
],
});
+
useMutation(BlockUser, {
connectionUpdates: [
({ data, append }) =>
Option.fromNullable(data.blockUser).map(({ user }) =>
append(blockedUsers, [user]),
),
({ data, prepend }) =>
Option.fromNullable(data.blockUser).map(({ user }) =>
prepend(lastBlockedUsers, [user]),
),
],
});

useMutation(Unfriend, {
connectionUpdates: [
({ data, variables, remove }) =>
Option.fromNullable(data.unfriend).map(() =>
remove(friends, [variables.id]),
),
],
});
\ No newline at end of file diff --git a/use-query/index.html b/use-query/index.html index e4b4fa7..d96a152 100644 --- a/use-query/index.html +++ b/use-query/index.html @@ -4,7 +4,7 @@ useQuery | GraphQL Client - +