Skip to content

Setting up Apollo with frameworks #460

Open
@lggwettmann

Description

@lggwettmann

Hey guys,

I've had quite some trouble setting up Apollo(-Boost) with Django cause the docs are not very extensive and difficult structured between Apollo, Vue-Apollo, Vue-Apollo-Boost (which doesn't seem to be documented at all).

I'd suggest adding a small section for all framework users out there. Eg for Django, I needed to find out about this to make CSRF protection work. Took me about three days.

Step 1> Install JS Cookie --> npm install --save js-cookie
Step 2> Add the CSRF token to the Apollo client header:

import ApolloClient from 'apollo-boost'
import VueApollo from 'vue-apollo'
import Cookies from 'js-cookie'
Vue.use(VueApollo)

const apolloProvider = new VueApollo({
  defaultClient: new ApolloClient({
    headers: {
      'X-CSRFToken': Cookies.get('csrftoken')
    }
  })

Done.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions