Navel Piercing Madness

    github-graphql-data-collection
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    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.

    Install

    npm i github-graphql-data-collection

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    1 MB

    Total Files

    20

    Last publish

    Collaborators

    • alan-cha