Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-apollo

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-apollo

Use Apollo and GraphQL with Vue.js

  • 3.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
128K
decreased by-11.93%
Maintainers
1
Weekly downloads
 
Created

What is vue-apollo?

vue-apollo is an integration of Apollo Client with Vue.js, allowing you to use GraphQL in your Vue applications. It provides a set of tools to manage GraphQL queries, mutations, and subscriptions, making it easier to interact with GraphQL APIs in a Vue.js environment.

What are vue-apollo's main functionalities?

Querying Data

This feature allows you to perform GraphQL queries to fetch data from a GraphQL server. The `useQuery` function is used to execute the query and manage the loading state, result, and any errors.

```javascript
import { useQuery, gql } from '@vue/apollo-composable';

const GET_USERS = gql`
  query GetUsers {
    users {
      id
      name
    }
  }
`;

export default {
  setup() {
    const { result, loading, error } = useQuery(GET_USERS);
    return { result, loading, error };
  }
};
```

Mutating Data

This feature allows you to perform GraphQL mutations to modify data on a GraphQL server. The `useMutation` function is used to execute the mutation and manage the loading state, result, and any errors.

```javascript
import { useMutation, gql } from '@vue/apollo-composable';

const ADD_USER = gql`
  mutation AddUser($name: String!) {
    addUser(name: $name) {
      id
      name
    }
  }
`;

export default {
  setup() {
    const { mutate, loading, error } = useMutation(ADD_USER);
    const addUser = (name) => {
      mutate({ variables: { name } });
    };
    return { addUser, loading, error };
  }
};
```

Subscriptions

This feature allows you to subscribe to real-time updates from a GraphQL server. The `useSubscription` function is used to execute the subscription and manage the loading state, result, and any errors.

```javascript
import { useSubscription, gql } from '@vue/apollo-composable';

const USER_ADDED = gql`
  subscription OnUserAdded {
    userAdded {
      id
      name
    }
  }
`;

export default {
  setup() {
    const { result, loading, error } = useSubscription(USER_ADDED);
    return { result, loading, error };
  }
};
```

Other packages similar to vue-apollo

Keywords

FAQs

Package last updated on 15 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc