Socket
Socket
Sign inDemoInstall

github-graphql-data-collection

Package Overview
Dependencies
12
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github-graphql-data-collection

Tool to collect data about the processing of GraphQL queries on the GitHub API


Version published
Maintainers
1
Install size
3.71 MB
Created

Readme

Source

GitHub GraphQL Query Generator

Generates random GraphQL queries for the GitHub GraphQL API.

Usage

Clone the example library.

Install the dependencies.

npm ci

The query generator dynamically creates providers by querying the GitHub API for data. In order to do so, you must provide your GitHub credentials.

Create a file named .env with your GitHub personal access token.

GITHUB_ACCESS_TOKEN={your access token}

Use the getGitHubQueryGenerator() factory method to create a GitHubQueryGenerator object, which can be used to generate queries.

require("dotenv").config()

const { getGitHubQueryGenerator } = require("./lib/index")
const { print } = require("graphql")

getGitHubQueryGenerator(process.env.GITHUB_ACCESS_TOKEN).then(
  (queryGenerator) => {
    const query = queryGenerator.generateRandomGitHubQuery()
    const { queryDocument, variableValues } = query

    console.log(print(queryDocument))
    console.log(JSON.stringify(variableValues, null, 2))
  }
)

Generating a query corpus

We provided a script that can generate a corpus of 5,000 randomly generated GitHub queries and responses.

To create the corpus, please provide your GitHub access token in a .env file, as described in the previous section.

Then, run:

npm run generate-corpus

The corpus will be saved into the query-corpus/ folder.

Disclaimer

Queries are associated with a particular version of a GraphQL schema. The generated GitHub queries are associated with this version of the GitHub schema.

Due to the natural evolution of the GitHub API, the generated queries may not work with the current version of the API. The generated queries may contain deprecated fields and the new API may require new arguments for certain fields. However, the generated queries are valid and would have worked with the version of the API at the time.

Keywords

FAQs

Last updated on 26 Feb 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc