1.5.6 • Published 4 years ago

@dotvirus/vue-axios-graphql v1.5.6

Weekly downloads
22
License
ISC
Repository
github
Last release
4 years ago

npm version

vue-axios-graphql

Install

main.js

import Vue from "vue";
const QLClient = require("@dotvirus/vue-axios-graphql");

Vue.use(QLClient, { url: "GRAPHQL_ENDPOINT" });

Nuxt

Create a plugin in plugins/

plugins/example.js

const { AxiosGraphQLClient } = require("@dotvirus/vue-axios-graphql");
const url = "GRAPHQL_ENDPOINT";

export default (ctx, inject) => {
  inject("ql", new AxiosGraphQLClient(url));
};

Register in nuxt config

nuxt.config.js

export default {
  // ...
  plugins: ["~/plugins/example.js"]
  // ...
};

The client is now exposed as this.$ql (client-side) and context.app.$ql (server-side).

Methods

query({ query, variables })

// Query (uses HTTP GET)
this.$ql.query({
  query: `
  {
    hello
  }
  `,
  variables: {/*...*/}, // Optional if no variables needed
  options: {/*...*/} // Optional
});

mutate({ mutation, variables })

// Mutation (uses HTTP POST)
this.$ql.mutate({
  mutation: `
  {
    hello
  }
  `,
  variables: {/*...*/}, // Optional if no variables needed
  options: {/*...*/} // Optional
});

Options

This package offers a wide range of options to customize to your needs

NameDescription
urlGraphQL endpoint
transformTransform request string before send

Type declaration

declare module "vue/types/vue" {
  interface Vue {
    $ql: AxiosGraphQLClient;
  }
}
1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1-b

5 years ago

1.0.1

5 years ago

1.0.0-d

5 years ago

1.0.0-c

5 years ago

1.0.0-b

5 years ago

1.0.0

5 years ago