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/create

v4.0.3

Published

Scaffold apps and components with GraphQL and Lit

Downloads

66

Readme

@apollo-elements/create

Published on npm Published on webcomponents.org ISC License Release

⚡️ App and Component Generator for Apollo Elements 🚀

🔎 Read the Full API Docs 🔎

To quickly get started with apollo-elements, generate a skeleton app with this command

npm init @apollo-elements

Which will prompt you to generate a full app, or a component thereof.

App Generator

npm init @apollo-elements -- app

Generate an Apollo Elements Skeleton App

Example

npm init @apollo-elements -- \
  app \
    --pkg-manager yarn \
    --uri '/graphql' \
    --install \
    --start \
    --overwrite

Options

| Flag | Description | type | default | | -------------------- | ------------------------------------------------------ | --------------- | ------- | | --help | Show help | boolean | | | --version | Show version number | boolean | | | --pkg-manager | Preferred package manager | npm or yarn | npm | | --uri, -u | URI to your GraphQL endpoint | string | | | --overwrite | Overwrite existing files | boolean | | | --package-defaults | Use default package.json fields (e.g. author, license) | boolean | | | --codegen | Run codegen after scaffolding files | boolean | true | | --install, -i | Automatically install dependencies | boolean | | | --start, -s | Launch the dev server after scaffolding | boolean | |

🔋 Batteries Included

The generated app comes with plenty of bells-and-whistles:

  • TypeScript
  • Linting with eslint and an opinionated ruleset
  • Buildless development workflow with @web/dev-server
  • Minified production bundle
  • A basic Apollo Client instance
  • Simple, unopinionated SPA routing
  • Code-generated TypeScript typings for GraphQL documents
  • import MyQuery from './My.query.graphql'
  • import styles from './my-element.css'

🛎 Scripts

These npm scripts help you get your work done in style:

npm start
yarn start

runs the code generator and the development server in watch mode

npm run build
yarn build

bundles the app into /build. The build will bundle and minify your javascript, and minify your HTML. Just upload to your static file host and you're good.

npm run lint
yarn lint

Lint your app with an opinionated set of rules for JavaScript and TypeScript

npm test
yarn test

The generator currently doesn't offer strong opinions on testing your UI components, so npm test currently exist with an error code. For unit testing business logic (i.e. typePolicies), we recommend @web/test-runner

Component Generator

npm init @apollo-elements -- component

Generate an Apollo Element

Example

npm init @apollo-elements -- \
  component \
    --type mutation \
    --name x-user-profile \
    --subdir user \
    --schema-path '#schema' \
    --shared-css-path '#components/shared.css' \
    --variables '$input: UpdateProfileInput!' \
    --fields 'updateProfile(input: $input) { id }' \
    --no-codegen
    --overwrite

Options

| Flag | Description | type | default | | ------------------- | --------------------------------------------------------- | -------------------------------------- | ------- | | --help | Show help | boolean | | | --version | Show version number | boolean | | | --pkg-manager | Preferred package manager | npm or yarn | npm | | --type, -t | Element type | query, mutation, or subscription | query | | --name, -n | Custom element tag name | string | | | --subdir, -d | Optional subdir under src/components | string | | | --overwrite | Overwrite existing files | boolean | false | | --codegen | Run codegen after scaffolding files | boolean | true | | --schema-path | Optional custom path to schema types file | string | | | --shared-css-path | Optional custom path to shared component styles file | string | | | --variables | Optional custom variables e.g. input: $UpdateUserInput | string | | | --fields | Optional custom fields e.g. id name picture { alt url } | string | |