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

@ndlib/graphql-harvest

v1.3.0

Published

An NPM plugin to fetch data from an arbitrary GraphQL data source

Downloads

33

Readme

GraphQL Harvest

An NPM plugin to fetch data from an arbitrary GraphQL data source

Configuration Parameters Needed

  • You will need a set of GraphQL queries in one or more files in a specified folder
  • If you have multiple files with queries that need to be run, you must import the queries into an index.ts file
  • An index.ts files is required - an example is given below
  • You will need an output directory where the retrieved data will be stored
  • You will need to name your query call to the GraphQL endpoint
  • You will need to full URL to your GraphQL endpoint

In Development Environment

  • Globally install typescript
  • There are several node modules listed in the dev dependencies list that should get installed locally - those are required for correct TypeScript type identification
  • If you are using this with Gatsby you will need to add parameters to your gatsby-config.ts file

Example of use

How to use (in gatsby-config.ts):

include * from './content/graphql'

module.exports = {
  plugins: [
    ...
    {
      resolve: '@ndlib/graphql-harvest',
      options: {
        query_name: <any-name-you-want>,
        graphql_endpoint: <full-url-to-graphql-endpoint>,
        query_types: <included-module-with-graphql-queries-present>,
        results_output_path: <path-to-output-folder-where-results-are-stored>
      }
    },
    ...
  ]
}

Example of index.ts file that assigned to the query_types folder:

export * as people from './people'
export * as subjects from './subjects'
export * as teams from './teams'
export * as units from './units'
export * as universityCommittees from './universityCommittees'

Each of the types referenced above will have a GraphQL query in it and will be included at harvest time. A corresponding JSON file will be created in the output folder named for the type it represents. For example, in the above index.ts file, a people.json file will be created upon completion of the harvest assuming that the query is syntactically correct and the endpoint provides data matching the query.

| Parameter | Description | Required | | ------------- |:-------------| ----- | | query_name | An arbitrary that will get passed to the endpoint which can be used to track query execution in the endpoint log files | yes | | graphql_endpoint | The full URL to the GraphQL endpoint | yes | | query_types | Included at the top of the gatsby_config.ts file - an index.(js|ts) file which includes all of the types being queried | yes | | results_output_path | The directory where the output files will be written - one JSON file per type included in the index.(js|ts) file | yes |