Search code examples
vue.jsapollovue-apollo

Http Headers vue-apollo


👩‍💻,

I have see many articles of how to use headers in apollo with context options but I don't know how to make it work in vue-apollo , is already other isssue in github about these (https://github.com/vuejs/vue-apollo/issues/713) config the vue-apollo.js, but I want to use headers to individuals querys, ¿Is these possible?.

My Query with vue-apollo:

apollo:{
            getPipedrivePersons: {
                query: gql`query{
                    getPipedrivePersons(
                        term:"email"
                    ){
                        id
                        name
                        detail{
                        firstName
                        lastName
                        }
                        email{
                        value
                        }
                        phone{
                        value
                        }
                    }
                    }
                `,
                pollInterval: 950,
                },
                
        }

Solution

  • solved by using context:

    context: {
       headers: { foo: this.fooHeader }
    }