npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@black-kro/use-apollo

v0.0.3

Published

***NOTE: This is a fork of [Vue Apollo V4 Composable](https://github.com/vuejs/vue-apollo/tree/v4/packages/vue-apollo-composable)***

Downloads

2

Readme

NOTE: This is a fork of Vue Apollo V4 Composable

useApollo

useApollo is a "fork" of vue-apollo that removes support from Vue 2.x and adds support for Apollo 3.x and Vue 3.x

Since this library is a fork of the original vue-apollo and only includes the apollo-composable portion of the library, only certain portions of the docs will be helpful to you.

Relevant Documentation

Vue Apollo - Composition API

Why?

The reason for this library fork is the Vue Apollo library does not currently support Apollo 3 and the support for Vue 3.x is not very good either. This fork hopes to resolve those issues until the official library has proper support for both Apollo 3 and Vue 3.x. This library will try its best to use the same API as the Vue Apollo library so when the official library is up to date it will be easy to switch back to it.

Installing

yarn add @black-kro/useApollo @apollo/client

Using

apollo.ts

import { ApolloClient, InMemoryCache, gql } from '@apollo/client/core';

export const client = new ApolloClient({
    uri: 'MY SERVER URL',
    cache: new InMemoryCache()
});

main.ts

import { createApp } from 'vue'
import App from './App.vue'

// Import DefaultApollo symbol from package and import your client.
import { DefaultApolloClient } from './composables';
import { client } from './apollo';

createApp(App)
    // Provide your client to the useApollo library.
    .provide(DefaultApolloClient, client)
    .mount('#app')

App.vue

<template>
    <div v-if="loading">Loading...</div>
    <div v-else-if="error">{{error}}</div>
    <div v-else-if="result">{{result}}</div>
</template>

<script setup>
    import { useQuery } from '@black-kro/useApollo';
    import { gql } from '@apollo/client/core';

    export const { loading, error, result } = useQuery(gql`
        query Me {
            me {
                id
                username
            }
        }
    `);
</script>

Non-Standard API's

  • useLazyQuery

    This works the same as useQuery except it will not auto run. To run the query you must use the fetch function on the object.

    const { fetch, result, loading, error } = useLazyQuery(...);
    
    fetch({ myVariables });

Troubleshooting

Vite

If you are using vite you may run into some troubles when attempting to create your Apollo Client, to resolve this create a vite.config.ts file like below to resolve the issues.

import { UserConfig } from 'vite';

const config: UserConfig = {
    optimizeDeps: {
        include: [
            'fast-json-stable-stringify',
            'zen-observable',
            'graphql-tag'
        ]
    },
    rollupInputOptions: {
        external: [
            'react',
        ]
    },
}

export default config;

License

MIT

Copyright (c) 2020-present, Black Kro