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

@apollo-elements/lit-apollo

v5.0.3

Published

πŸ‘©β€πŸš€πŸŒ› Lit meets Apollo GraphQL πŸš€πŸ‘¨β€πŸš€

Downloads

3,124

Readme

@apollo-elements/lit-apollo

Published on npm Published on webcomponents.org ISC License Release

πŸš€ Lit base classes that connect to your Apollo cache 🌜

πŸ‘©β€πŸš€ It's one small step for a dev, one giant leap for the web platform! πŸ‘¨β€πŸš€

This package is for single-operation GraphQL components. Looking for Apollo Reactive Controllers? See @apollo-elements/core

View Live Demo

πŸ”Ž Read the Full API Docs πŸ”Ž

πŸ““ Contents

πŸ”§ Installation

Apollo Elements' lit-apollo is distributed through npm, the node package manager. To install a copy of the latest version in your project's node_modules directory, install npm on your system then run the following command in your project's root directory:

npm install --save @apollo-elements/lit-apollo

πŸ‘©β€πŸš€ Usage

See our docs on setting up Apollo client so your components can fetch their data.

First, let's define our component's GraphQL query.

query HelloQuery {
  helloWorld {
    name
    greeting
  }
}

Read our docs on working with GraphQL files during development and in production for more info, and be sure to read about generating TypeScript types from GraphQL to enhance your developer experience and reduce bugs.

Next, we'll define our UI component. Import the base class and helpers, query, and types:

import { ApolloQuery, html, customElement } from '@apollo-elements/lit-apollo';

import HelloQuery from './Hello.query.graphql';

import type {
  HelloQueryData as Data,
  HelloQueryVariables as Variables
} from '../codegen/schema';

Then define your component's template. Make sure to set the query field, so your component starts fetching data automatically.

@customElement('hello-query')
export class HelloQueryElement extends ApolloQuery<Data, Variables> {
  query = HelloQuery;

  render() {
    return html`
      <what-spin-such-loader ?active="${this.loading}"></what-spin-such-loader>
    ${(
      this.error ? html`
        <h1>😒 Such Sad, Very Error! 😰</h1>
        <pre><code>${error.message}</code></pre>`
    : html`
        <p>
          ${this.data?.helloWorld.greeting ?? 'Hello'},
          ${this.data?.helloWorld.name ?? 'Friend'}!
        </p>`
    )}
    `;
   }
}

πŸ“š Other Libraries

Looking for other libraries? Want to use Apollo with vanilla extends HTMLElement components? Check out our docs site

πŸ‘·β€β™‚οΈ Maintainers

apollo-elements is a community project maintained by Benny Powers.

Contact me on Codementor