Skip to content

Nuxt + @vue/apollo-composable - fetch only by server #1022

Open
@tcastelly

Description

@tcastelly

Describe the bug
I'm using Nuxt. I would want to be able to fetch queries defined by @vue/apollo-composable by the client.

It works with the default component creation

export default {
  name: 'Graphql',
  apollo: {
    testQuery: {
      prefetch: false, // <--
      query: TestQuery,
    },
  },
}

But not with the composition-api

export default defineComponent({
  setup() {
    const { result } = useQuery(TestQuery, {}, {
      prefetch: false, // <--
    });

    return {
      result,
    };
  },
});

The current behavior that I have, is a pending query. If I replace the prefetch: false by fetchPolicy: 'no-cache' I have an Ajax query AND a fetch by the server.

export default defineComponent({
  setup() {
    const { result } = useQuery(TestQuery, {}, {
      fetchPolicy: 'no-cache',
      //      prefetch: false,
    });

    return {
      result,
    };
  },
});

To Reproduce

  1. Checkout this project: https://github.com/shenron/vue-nuxt-tsx
  2. Try the page grahpql.vue and graphql_composition.vue

Expected behavior
To be able to fetch only by the client

Versions
vue: 2.6.11
vue-apollo: 3.0.3
apollo-client: 2.6.10

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