Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cookie as a variable for Query in Apollo #3

Open
gijo-varghese opened this issue Feb 2, 2018 · 0 comments
Open

Use cookie as a variable for Query in Apollo #3

gijo-varghese opened this issue Feb 2, 2018 · 0 comments

Comments

@gijo-varghese
Copy link

I'm https://github.com/S64/vue-universal-cookies to use cookies on both server side and client side. This library works perfectly. However if I use it as a variable in the query, it doesn't work. Any idea?

<template>
 <div>
  {{ $cookies.get('customerId') }} // this works
 </div>
</template>
<script>
import CUSTOMER from "~/graphql/queries/CUSTOMER.gql";

export default {
created() {
  console.log(this.$cookies.get('customerId)) // this works on both server and client
},
  apollo: {
    customer: {
      query: CUSTOMER,
      prefetch: true,
      variables(){
        return {
         customerId: this.$cookies.get('customerId) // this doesn't work
        }
      }
   }
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant