feat: gql codegen + caching + optimistic

This commit is contained in:
Andrew Bastin
2021-10-08 23:44:23 +05:30
parent a5fd39adf8
commit 337a60c8a4
24 changed files with 1202 additions and 418 deletions

View File

@@ -73,11 +73,11 @@
import { useContext } from "@nuxtjs/composition-api"
import { pipe } from "fp-ts/function"
import * as TE from "fp-ts/TaskEither"
import { TeamMemberRole } from "~/helpers/backend/graphql"
import {
deleteTeam as backendDeleteTeam,
leaveTeam,
} from "~/helpers/backend/mutations/Team"
import { TeamMemberRole } from "~/helpers/backend/types/TeamMemberRole"
const props = defineProps<{
team: {

View File

@@ -71,12 +71,15 @@
</template>
<script setup lang="ts">
import { gql } from "@apollo/client/core"
import { ref, watchEffect } from "@nuxtjs/composition-api"
import * as E from "fp-ts/Either"
import { useGQLQuery } from "~/helpers/backend/GQLClient"
import {
MyTeamsDocument,
MyTeamsQuery,
MyTeamsQueryVariables,
} from "~/helpers/backend/graphql"
import { MyTeamsQueryError } from "~/helpers/backend/QueryErrors"
import { TeamMemberRole } from "~/helpers/backend/types/TeamMemberRole"
defineProps<{
modal: boolean
@@ -88,47 +91,10 @@ const editingTeam = ref<any>({}) // TODO: Check this out
const editingTeamID = ref<any>("")
const myTeams = useGQLQuery<
{
myTeams: Array<{
id: string
name: string
myRole: TeamMemberRole
ownersCount: number
members: Array<{
membershipID: string
user: {
photoURL: string | null
displayName: string
email: string
uid: string
}
role: TeamMemberRole
}>
}>
},
MyTeamsQuery,
MyTeamsQueryVariables,
MyTeamsQueryError
>(
gql`
query GetMyTeams {
myTeams {
id
name
myRole
ownersCount
members {
membershipID
user {
photoURL
displayName
email
uid
}
role
}
}
}
`
)
>(MyTeamsDocument)
watchEffect(() => {
console.log(myTeams)