feat: mutations and queries for shortcode management
This commit is contained in:
@@ -4,5 +4,6 @@ export const keyDefs: GraphCacheKeysConfig = {
|
|||||||
User: (data) => data.uid!,
|
User: (data) => data.uid!,
|
||||||
TeamMember: (data) => data.membershipID!,
|
TeamMember: (data) => data.membershipID!,
|
||||||
Team: (data) => data.id!,
|
Team: (data) => data.id!,
|
||||||
|
Shortcode: (data) => data.id!,
|
||||||
TeamInvitation: (data) => data.id!,
|
TeamInvitation: (data) => data.id!,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,9 @@ export const resolversDef: GraphCacheResolvers = {
|
|||||||
__typename: "TeamInvitation",
|
__typename: "TeamInvitation",
|
||||||
id: args.inviteID,
|
id: args.inviteID,
|
||||||
}),
|
}),
|
||||||
|
shortcode: (_parent, args, _cache, _info) => ({
|
||||||
|
__typename: "Shortcode",
|
||||||
|
id: args.code,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { gql } from "@urql/core"
|
||||||
import { GraphCacheUpdaters, MyTeamsDocument } from "../graphql"
|
import { GraphCacheUpdaters, MyTeamsDocument } from "../graphql"
|
||||||
|
|
||||||
export const updatesDef: GraphCacheUpdaters = {
|
export const updatesDef: GraphCacheUpdaters = {
|
||||||
@@ -168,5 +169,19 @@ export const updatesDef: GraphCacheUpdaters = {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
createShortcode: (result, _args, cache, _info) => {
|
||||||
|
cache.writeFragment(
|
||||||
|
gql`
|
||||||
|
fragment _ on Shortcode {
|
||||||
|
id
|
||||||
|
request
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
{
|
||||||
|
id: result.createShortcode.id,
|
||||||
|
request: result.createShortcode.request,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
mutation CreateShortcode($request: String!) {
|
||||||
|
createShortcode(request: $request) {
|
||||||
|
id
|
||||||
|
request
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
query ResolveShortcode($code: ID!) {
|
||||||
|
shortcode(code: $code) {
|
||||||
|
id
|
||||||
|
request
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { runMutation } from "../GQLClient"
|
||||||
|
import {
|
||||||
|
CreateShortcodeDocument,
|
||||||
|
CreateShortcodeMutation,
|
||||||
|
CreateShortcodeMutationVariables,
|
||||||
|
} from "../graphql"
|
||||||
|
import { HoppRESTRequest } from "~/helpers/types/HoppRESTRequest"
|
||||||
|
|
||||||
|
export const createShortcode = (request: HoppRESTRequest) =>
|
||||||
|
runMutation<CreateShortcodeMutation, CreateShortcodeMutationVariables, "">(
|
||||||
|
CreateShortcodeDocument,
|
||||||
|
{
|
||||||
|
request: JSON.stringify(request),
|
||||||
|
}
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user