Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

refactor: update ID based backend queries to proper types

Andrew Bastinc71333d9cb57
diff --git a/packages/hoppscotch-app/components/collections/index.vue b/packages/hoppscotch-app/components/collections/index.vue
index 019aacbf5..90a80f5ac 100644
--- a/packages/hoppscotch-app/components/collections/index.vue
+++ b/packages/hoppscotch-app/components/collections/index.vue
@@ -506,7 +506,7 @@ export default defineComponent({
mutation: gql`
mutation CreateChildCollection(
$childTitle: String!
- $collectionID: String!
+ $collectionID: ID!
) {
createChildCollection(
childTitle: $childTitle
@@ -613,7 +613,7 @@ export default defineComponent({
.mutate({
// Query
mutation: gql`
- mutation ($collectionID: String!) {
+ mutation ($collectionID: ID!) {
deleteCollection(collectionID: $collectionID)
}
`,
diff --git a/packages/hoppscotch-app/helpers/teams/TeamCollectionAdapter.ts b/packages/hoppscotch-app/helpers/teams/TeamCollectionAdapter.ts
index 73c01a72e..ce80629de 100644
--- a/packages/hoppscotch-app/helpers/teams/TeamCollectionAdapter.ts
+++ b/packages/hoppscotch-app/helpers/teams/TeamCollectionAdapter.ts
@@ -382,7 +382,7 @@ export default class TeamCollectionAdapter {
this.teamCollectionAdded$ = apolloClient
.subscribe({
query: gql`
- subscription TeamCollectionAdded($teamID: String!) {
+ subscription TeamCollectionAdded($teamID: ID!) {
teamCollectionAdded(teamID: $teamID) {
id
title
@@ -411,7 +411,7 @@ export default class TeamCollectionAdapter {
this.teamCollectionUpdated$ = apolloClient
.subscribe({
query: gql`
- subscription TeamCollectionUpdated($teamID: String!) {
+ subscription TeamCollectionUpdated($teamID: ID!) {
teamCollectionUpdated(teamID: $teamID) {
id
title
@@ -435,7 +435,7 @@ export default class TeamCollectionAdapter {
this.teamCollectionRemoved$ = apolloClient
.subscribe({
query: gql`
- subscription TeamCollectionRemoved($teamID: String!) {
+ subscription TeamCollectionRemoved($teamID: ID!) {
teamCollectionRemoved(teamID: $teamID)
}
`,
@@ -450,7 +450,7 @@ export default class TeamCollectionAdapter {
this.teamRequestAdded$ = apolloClient
.subscribe({
query: gql`
- subscription TeamRequestAdded($teamID: String!) {
+ subscription TeamRequestAdded($teamID: ID!) {
teamRequestAdded(teamID: $teamID) {
id
collectionID
@@ -477,7 +477,7 @@ export default class TeamCollectionAdapter {
this.teamRequestUpdated$ = apolloClient
.subscribe({
query: gql`
- subscription TeamRequestUpdated($teamID: String!) {
+ subscription TeamRequestUpdated($teamID: ID!) {
teamRequestUpdated(teamID: $teamID) {
id
collectionID
@@ -502,7 +502,7 @@ export default class TeamCollectionAdapter {
this.teamRequestDeleted$ = apolloClient
.subscribe({
query: gql`
- subscription TeamRequestDeleted($teamID: String!) {
+ subscription TeamRequestDeleted($teamID: ID!) {
teamRequestDeleted(teamID: $teamID)
}
`,
diff --git a/packages/hoppscotch-app/helpers/teams/TeamMemberAdapter.ts b/packages/hoppscotch-app/helpers/teams/TeamMemberAdapter.ts
index ab2b651e2..77ca87230 100644
--- a/packages/hoppscotch-app/helpers/teams/TeamMemberAdapter.ts
+++ b/packages/hoppscotch-app/helpers/teams/TeamMemberAdapter.ts
@@ -56,7 +56,7 @@ export default class TeamMemberAdapter {
while (true) {
const response: Apollo.ApolloQueryResult<any> = await apolloClient.query({
query: gql`
- query GetTeamMembers($teamID: String!, $cursor: String) {
+ query GetTeamMembers($teamID: ID!, $cursor: ID) {
team(teamID: $teamID) {
members(cursor: $cursor) {
membershipID
@@ -92,7 +92,7 @@ export default class TeamMemberAdapter {
this.teamMemberAdded$ = apolloClient
.subscribe({
query: gql`
- subscription TeamMemberAdded($teamID: String!) {
+ subscription TeamMemberAdded($teamID: ID!) {
teamMemberAdded(teamID: $teamID) {
user {
uid
@@ -113,7 +113,7 @@ export default class TeamMemberAdapter {
this.teamMemberRemoved$ = apolloClient
.subscribe({
query: gql`
- subscription TeamMemberRemoved($teamID: String!) {
+ subscription TeamMemberRemoved($teamID: ID!) {
teamMemberRemoved(teamID: $teamID)
}
`,
@@ -132,7 +132,7 @@ export default class TeamMemberAdapter {
this.teamMemberUpdated$ = apolloClient
.subscribe({
query: gql`
- subscription TeamMemberUpdated($teamID: String!) {
+ subscription TeamMemberUpdated($teamID: ID!) {
teamMemberUpdated(teamID: $teamID) {
user {
uid
diff --git a/packages/hoppscotch-app/helpers/teams/utils.js b/packages/hoppscotch-app/helpers/teams/utils.js
index 5d57e2b9d..1772ed323 100644
--- a/packages/hoppscotch-app/helpers/teams/utils.js
+++ b/packages/hoppscotch-app/helpers/teams/utils.js
@@ -14,7 +14,7 @@ export async function getLiveTeamMembersList(apollo, teamID) {
const { data } = await apollo.query({
query: gql`
- query GetTeamMembers($teamID: String!) {
+ query GetTeamMembers($teamID: ID!) {
team(teamID: $teamID) {
members {
user {
@@ -36,7 +36,7 @@ export async function getLiveTeamMembersList(apollo, teamID) {
const addedSub = apollo
.subscribe({
query: gql`
- subscription TeamMemberAdded($teamID: String!) {
+ subscription TeamMemberAdded($teamID: ID!) {
teamMemberAdded(teamID: $teamID) {
user {
uid
@@ -57,7 +57,7 @@ export async function getLiveTeamMembersList(apollo, teamID) {
const updateSub = apollo
.subscribe({
query: gql`
- subscription TeamMemberUpdated($teamID: String!) {
+ subscription TeamMemberUpdated($teamID: ID!) {
teamMemberUpdated(teamID: $teamID) {
user {
uid
@@ -84,7 +84,7 @@ export async function getLiveTeamMembersList(apollo, teamID) {
const removeSub = apollo
.subscribe({
query: gql`
- subscription TeamMemberRemoved($teamID: String!) {
+ subscription TeamMemberRemoved($teamID: ID!) {
teamMemberRemoved(teamID: $teamID)
}
`,
@@ -134,7 +134,7 @@ export function addTeamMemberByEmail(apollo, userRole, userEmail, teamID) {
mutation addTeamMemberByEmail(
$userRole: TeamMemberRole!
$userEmail: String!
- $teamID: String!
+ $teamID: ID!
) {
addTeamMemberByEmail(
userRole: $userRole
@@ -159,7 +159,7 @@ export function updateTeamMemberRole(apollo, userID, newRole, teamID) {
mutation updateTeamMemberRole(
$newRole: TeamMemberRole!
$userUid: String!
- $teamID: String!
+ $teamID: ID!
) {
updateTeamMemberRole(
newRole: $newRole
@@ -181,7 +181,7 @@ export function updateTeamMemberRole(apollo, userID, newRole, teamID) {
export function renameTeam(apollo, name, teamID) {
return apollo.mutate({
mutation: gql`
- mutation renameTeam($newName: String!, $teamID: String!) {
+ mutation renameTeam($newName: String!, $teamID: ID!) {
renameTeam(newName: $newName, teamID: $teamID) {
id
}
@@ -197,7 +197,7 @@ export function renameTeam(apollo, name, teamID) {
export function removeTeamMember(apollo, userID, teamID) {
return apollo.mutate({
mutation: gql`
- mutation removeTeamMember($userUid: String!, $teamID: String!) {
+ mutation removeTeamMember($userUid: String!, $teamID: ID!) {
removeTeamMember(userUid: $userUid, teamID: $teamID)
}
`,
@@ -213,7 +213,7 @@ export async function deleteTeam(apollo, teamID) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($teamID: String!) {
+ mutation ($teamID: ID!) {
deleteTeam(teamID: $teamID)
}
`,
@@ -229,7 +229,7 @@ export async function deleteTeam(apollo, teamID) {
export function exitTeam(apollo, teamID) {
return apollo.mutate({
mutation: gql`
- mutation ($teamID: String!) {
+ mutation ($teamID: ID!) {
leaveTeam(teamID: $teamID)
}
`,
@@ -245,7 +245,7 @@ export async function rootCollectionsOfTeam(apollo, teamID) {
while (true) {
const response = await apollo.query({
query: gql`
- query rootCollectionsOfTeam($teamID: String!, $cursor: String!) {
+ query rootCollectionsOfTeam($teamID: ID!, $cursor: ID!) {
rootCollectionsOfTeam(teamID: $teamID, cursor: $cursor) {
id
title
@@ -271,7 +271,7 @@ export async function getCollectionChildren(apollo, collectionID) {
const children = []
const response = await apollo.query({
query: gql`
- query getCollectionChildren($collectionID: String!) {
+ query getCollectionChildren($collectionID: ID!) {
collection(collectionID: $collectionID) {
children {
id
@@ -297,7 +297,7 @@ export async function getCollectionRequests(apollo, collectionID) {
while (true) {
const response = await apollo.query({
query: gql`
- query getCollectionRequests($collectionID: String!, $cursor: String) {
+ query getCollectionRequests($collectionID: ID!, $cursor: ID) {
requestsInCollection(collectionID: $collectionID, cursor: $cursor) {
id
title
@@ -329,7 +329,7 @@ export async function renameCollection(apollo, title, id) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($newTitle: String!, $collectionID: String!) {
+ mutation ($newTitle: String!, $collectionID: ID!) {
renameCollection(newTitle: $newTitle, collectionID: $collectionID) {
id
}
@@ -350,7 +350,7 @@ export async function updateRequest(apollo, request, requestName, requestID) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($data: UpdateTeamRequestInput!, $requestID: String!) {
+ mutation ($data: UpdateTeamRequestInput!, $requestID: ID!) {
updateRequest(data: $data, requestID: $requestID) {
id
}
@@ -374,7 +374,7 @@ export async function addChildCollection(apollo, title, id) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($childTitle: String!, $collectionID: String!) {
+ mutation ($childTitle: String!, $collectionID: ID!) {
createChildCollection(
childTitle: $childTitle
collectionID: $collectionID
@@ -398,7 +398,7 @@ export async function deleteCollection(apollo, id) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($collectionID: String!) {
+ mutation ($collectionID: ID!) {
deleteCollection(collectionID: $collectionID)
}
`,
@@ -416,7 +416,7 @@ export async function deleteRequest(apollo, requestID) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($requestID: String!) {
+ mutation ($requestID: ID!) {
deleteRequest(requestID: $requestID)
}
`,
@@ -434,7 +434,7 @@ export async function createNewRootCollection(apollo, title, id) {
while (true) {
response = await apollo.mutate({
mutation: gql`
- mutation ($title: String!, $teamID: String!) {
+ mutation ($title: String!, $teamID: ID!) {
createRootCollection(title: $title, teamID: $teamID) {
id
}
@@ -459,7 +459,7 @@ export async function saveRequestAsTeams(
) {
const x = await apollo.mutate({
mutation: gql`
- mutation ($data: CreateTeamRequestInput!, $collectionID: String!) {
+ mutation ($data: CreateTeamRequestInput!, $collectionID: ID!) {
createRequestInCollection(data: $data, collectionID: $collectionID) {
id
collection {
@@ -487,10 +487,7 @@ export async function saveRequestAsTeams(
export async function overwriteRequestTeams(apollo, request, title, requestID) {
await apollo.mutate({
mutation: gql`
- mutation updateRequest(
- $data: UpdateTeamRequestInput!
- $requestID: String!
- ) {
+ mutation updateRequest($data: UpdateTeamRequestInput!, $requestID: ID!) {
updateRequest(data: $data, requestID: $requestID) {
id
title
@@ -512,7 +509,7 @@ export async function importFromMyCollections(apollo, collectionID, teamID) {
mutation: gql`
mutation importFromMyCollections(
$fbCollectionPath: String!
- $teamID: String!
+ $teamID: ID!
) {
importCollectionFromUserFirestore(
fbCollectionPath: $fbCollectionPath
@@ -534,7 +531,7 @@ export async function importFromMyCollections(apollo, collectionID, teamID) {
export async function importFromJSON(apollo, collections, teamID) {
const response = await apollo.mutate({
mutation: gql`
- mutation importFromJSON($jsonString: String!, $teamID: String!) {
+ mutation importFromJSON($jsonString: String!, $teamID: ID!) {
importCollectionsFromJSON(jsonString: $jsonString, teamID: $teamID)
}
`,
@@ -549,7 +546,7 @@ export async function importFromJSON(apollo, collections, teamID) {
export async function replaceWithJSON(apollo, collections, teamID) {
const response = await apollo.mutate({
mutation: gql`
- mutation replaceWithJSON($jsonString: String!, $teamID: String!) {
+ mutation replaceWithJSON($jsonString: String!, $teamID: ID!) {
replaceCollectionsWithJSON(jsonString: $jsonString, teamID: $teamID)
}
`,
@@ -564,7 +561,7 @@ export async function replaceWithJSON(apollo, collections, teamID) {
export async function exportAsJSON(apollo, teamID) {
const response = await apollo.query({
query: gql`
- query exportAsJSON($teamID: String!) {
+ query exportAsJSON($teamID: ID!) {
exportCollectionsToJSON(teamID: $teamID)
}
`,
diff --git a/packages/hoppscotch-app/package.json b/packages/hoppscotch-app/package.json
index 24d27dbe1..aa76230f8 100644
--- a/packages/hoppscotch-app/package.json
+++ b/packages/hoppscotch-app/package.json
@@ -48,6 +48,7 @@
"graphql": "^15.6.0",
"graphql-language-service-interface": "^2.8.4",
"graphql-language-service-parser": "^1.9.2",
+ "graphql-tag": "^2.12.5",
"json-loader": "^0.5.7",
"lodash": "^4.17.21",
"mustache": "^4.2.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1d3297026..ca07a8838 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -69,6 +69,7 @@ importers:
graphql: ^15.6.0
graphql-language-service-interface: ^2.8.4
graphql-language-service-parser: ^1.9.2
+ graphql-tag: ^2.12.5
jest: ^27.2.2
jest-serializer-vue: ^2.0.2
json-loader: ^0.5.7
@@ -127,6 +128,7 @@ importers:
graphql: 15.6.0
graphql-language-service-interface: [email protected]
graphql-language-service-parser: [email protected]
+ graphql-tag: [email protected]
json-loader: 0.5.7
lodash: 4.17.21
mustache: 4.2.0
@@ -138,7 +140,7 @@ importers:
socketio-wildcard: 2.0.0
splitpanes: 2.3.8
tern: 0.24.3
- vue-apollo: 3.0.8
+ vue-apollo: [email protected]
vue-cli-plugin-apollo: [email protected]
vue-functional-data-merge: 3.1.0
vue-github-button: 1.3.0
@@ -12579,6 +12581,7 @@ packages:
/nan/2.15.0:
resolution: {integrity: sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==}
+ requiresBuild: true
dev: false
optional: true
@@ -17362,12 +17365,13 @@ packages:
deprecated: Sorry but vue-analytics is no longer maintained. I would suggest you switch to vue-gtag, with love, the guy who made the package.
dev: true
- /vue-apollo/3.0.8:
+ /vue-apollo/[email protected]:
resolution: {integrity: sha512-RnkC75PMoGwl1sdZdVO3R9P51wqmgOVi4QmljkBaTzlVThVlqfkJhrBcPiw2K9EohvSagvZclNqXktyOCcXbBA==}
peerDependencies:
graphql-tag: ^2
dependencies:
chalk: 2.4.2
+ graphql-tag: [email protected]
serialize-javascript: 4.0.0
throttle-debounce: 2.3.0
dev: false