"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-app/helpers/backend/caching/updates.ts" between
hoppscotch-2.2.1.tar.gz and hoppscotch-3.0.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

updates.ts  (hoppscotch-2.2.1):updates.ts  (hoppscotch-3.0.0)
import { gql } from "@urql/core" import { gql } from "@urql/core"
import { GraphCacheUpdaters, MyTeamsDocument } from "../graphql" import { GraphCacheUpdaters } from "../graphql"
export const updatesDef: GraphCacheUpdaters = { export const updatesDef: GraphCacheUpdaters = {
Subscription: { Subscription: {
teamMemberAdded: (_r, { teamID }, cache, _info) => { teamMemberAdded: (_r, { teamID }, cache) => {
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: teamID, id: teamID,
}, },
"teamMembers" "teamMembers"
) )
}, },
teamMemberUpdated: (_r, { teamID }, cache, _info) => { teamMemberUpdated: (_r, { teamID }, cache) => {
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: teamID, id: teamID,
}, },
"teamMembers" "teamMembers"
) )
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: teamID, id: teamID,
}, },
"myRole" "myRole"
) )
}, },
teamMemberRemoved: (_r, { teamID }, cache, _info) => { teamMemberRemoved: (_r, { teamID }, cache) => {
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: teamID, id: teamID,
}, },
"teamMembers" "teamMembers"
) )
}, },
teamInvitationAdded: (_r, { teamID }, cache, _info) => { teamInvitationAdded: (_r, { teamID }, cache) => {
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: teamID, id: teamID,
}, },
"teamInvitations" "teamInvitations"
) )
}, },
teamInvitationRemoved: (_r, { teamID }, cache, _info) => { teamInvitationRemoved: (_r, { teamID }, cache) => {
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: teamID, id: teamID,
}, },
"teamInvitations" "teamInvitations"
) )
}, },
}, },
Mutation: { Mutation: {
deleteTeam: (_r, { teamID }, cache, _info) => { createTeamInvitation: (result, _args, cache) => {
cache.updateQuery(
{
query: MyTeamsDocument,
},
(data) => {
if (data) {
data.myTeams = data.myTeams.filter((x) => x.id !== teamID)
}
return data
}
)
cache.invalidate({
__typename: "Team",
id: teamID,
})
},
leaveTeam: (_r, { teamID }, cache, _info) => {
cache.updateQuery(
{
query: MyTeamsDocument,
},
(data) => {
if (data) {
data.myTeams = data.myTeams.filter((x) => x.id !== teamID)
}
return data
}
)
cache.invalidate({
__typename: "Team",
id: teamID,
})
},
createTeam: (result, _args, cache, _info) => {
cache.updateQuery(
{
query: MyTeamsDocument,
},
(data) => {
if (data) data.myTeams.push(result.createTeam as any)
return data
}
)
},
removeTeamMember: (_result, { teamID, userUid }, cache) => {
const newMembers = (
(cache.resolve(
{
__typename: "Team",
id: teamID,
},
"teamMembers"
) as string[]) ?? []
)
.map((x) => [x, cache.resolve(x, "user") as string])
.map(([key, userKey]) => [key, cache.resolve(userKey, "uid") as string])
.filter(([_key, uid]) => uid !== userUid)
.map(([key]) => key)
cache.link({ __typename: "Team", id: teamID }, "teamMembers", newMembers)
},
createTeamInvitation: (result, _args, cache, _info) => {
cache.invalidate( cache.invalidate(
{ {
__typename: "Team", __typename: "Team",
id: result.createTeamInvitation.teamID!, id: result.createTeamInvitation.teamID!,
}, },
"teamInvitations" "teamInvitations"
) )
}, },
acceptTeamInvitation: (_result, _args, cache, _info) => { acceptTeamInvitation: (_result, _args, cache) => {
cache.invalidate({ __typename: "Query" }, "myTeams") cache.invalidate({ __typename: "Query" }, "myTeams")
}, },
revokeTeamInvitation: (_result, args, cache, _info) => { revokeTeamInvitation: (_result, args, cache) => {
const targetTeamID = cache.resolve( const targetTeamID = cache.resolve(
{ {
__typename: "TeamInvitation", __typename: "TeamInvitation",
id: args.inviteID, id: args.inviteID,
}, },
"teamID" "teamID"
) )
if (typeof targetTeamID === "string") { if (typeof targetTeamID === "string") {
const newInvites = ( const newInvites = (
skipping to change at line 172 skipping to change at line 107
}) })
) )
cache.link( cache.link(
{ __typename: "Team", id: targetTeamID }, { __typename: "Team", id: targetTeamID },
"teamInvitations", "teamInvitations",
newInvites newInvites
) )
} }
}, },
createShortcode: (result, _args, cache, _info) => { createShortcode: (result, _args, cache) => {
cache.writeFragment( cache.writeFragment(
gql` gql`
fragment _ on Shortcode { fragment _ on Shortcode {
id id
request request
} }
`, `,
{ {
id: result.createShortcode.id, id: result.createShortcode.id,
request: result.createShortcode.request, request: result.createShortcode.request,
 End of changes. 10 change blocks. 
75 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)