Giter VIP home page Giter VIP logo

Comments (6)

Akryum avatar Akryum commented on April 27, 2024 19

Hi!

The result object you get from your GraphQL server is:

{event: {title: "New event"} }

Where the top-level object has the result of your GraphQL query with the same name 'event' (it is necessary because you can call multiple GraphQL queries in one Apollo query).

But since you are calling your component's attribute title, it expects to have a result like this:

{ title: '...' }

In your case, it can't figure on its own what to do with the result, so you have to put an additional parameter, update, as described here:

<template>
  <div class="container-fluid">
    <h1>{{ title }}</h1>
  </div>
</template>
<script>
  import gql from "graphql-tag"

  export default {
    data: () => ({
      title: ""
    }),
    apollo: {
      title: {
        query: gql`{
          event {
            title
          }
        }`,
        update(data) {
          return data.event.title;
        ),
      }
    }
  }
</script>

from apollo.

Akryum avatar Akryum commented on April 27, 2024 7

You can also write (in ES2016):

update: ({ event }) => event.title,

from apollo.

ndarilek avatar ndarilek commented on April 27, 2024

from apollo.

Akryum avatar Akryum commented on April 27, 2024

Any idea about the simple queries without the query: key? They no
longer seem to work as documented.

Fixed in release 1.0.0-rc.2

from apollo.

emahuni avatar emahuni commented on April 27, 2024

Hi. Great package! I am not sure this was fixed seeing that it is still happening. I am brand new to this package and i followed the example in Usage in Vue exactly as given and it seems like I ran into this issue. I got it working after implementing the workaround update.... So reopen this please or should i create another issue?

from apollo.

emahuni avatar emahuni commented on April 27, 2024

ok just opened another, don't bother reopening this

from apollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.