Skip to content

Best practices for usage within Pinia actions #458

Answered by slavanossar
slavanossar asked this question in Q&A
Discussion options

You must be logged in to vote

After playing around with this more I've realised Approach B is the way to go, here's an example for anyone else who needs help on this (using Setup store syntax):

import { defineStore } from 'pinia'

import type {
  CustomerAccessTokenCreateMutation,
  CustomerAccessTokenCreateMutationVariables,
  CustomerFragment,
} from '@/shopify-types'

import { CustomerAccessTokenCreateDocument } from '@/graphql/exports'

export const useAccountStore = defineStore('account', () => {
  const config = useRuntimeConfig()

  let customer: CustomerFragment | null = ref(null)
  let customerAccessToken: string = ref('')

  function createCustomerAccessToken(
    variables: CustomerAccessTokenCreateMutation…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by slavanossar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant