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

@theconcurrent/query-generator

v0.0.33

Published

GraphQL Code Generator plugin for generating operation queries based on resources.

Downloads

17

Readme

@theconcurrent/query-generator

Table of Contents

Introduction

@theconcurrent/query-generator is an innovative GraphQL Code Generator plugin designed for both low-code and no-code environments. It's a powerful GraphQL tool that automates the process of query generation from your GraphQL schema. With @theconcurrent/query-generator, you can generate GraphQL queries automatically, making GraphQL development much more efficient and error-free.

It's perfect for any development process from low-code to no-code scenarios. Embrace the trend of automated query generation and make your development process more efficient with @theconcurrent/query-generator. Experience the ease of use that comes with a tool that fits seamlessly into your GraphQL automation tools kit. Make your project more visible and approachable for developers of all levels of experience, from no-code enthusiasts to seasoned professionals. Try @theconcurrent/query-generator today!

Why should you use @theconcurrent/query-generator?

  1. Automate Query Generation Writing queries manually based on your GraphQL schema can be a time-consuming task. However, using this plugin, you can greatly reduce the effort required.

  2. Prevent Errors When writing queries manually, mistakes such as using incorrect field names or writing queries that do not match the schema are common. This plugin generates queries based on your schema, thus preventing such errors.

  3. Ease of Maintenance When your schema changes, you need to update all related queries. But with this plugin, you can resolve this issue by simply generating new query documents.

If you want to utilize cutting-edge technology for efficient development, try @theconcurrent/query-generator. It may be the step to elevate your project to a new level.

Getting Started

To install @theconcurrent/query-generator, you need to have the GraphQL Code Generator installed first.

yarn add -d @graphql-codegen/cli
yarn add -d @theconcurrent/query-generator

Next, create a codegen.yml file to configure your GraphQL Code Generator. This file specifies your GraphQL schema file, the output file for the generated queries, and the plugins you want to use:

# codegen.yml
schema:
  - ./schema.graphql
generates:
  queries.graphql:
    plugins:
      - '@theconcurrent/query-generator'
    config:
      concurrent: ./config.json

You'll also need a config.json file that contains configuration details for the @theconcurrent framework. This includes the paths to the different GraphQL resources you want to query:

// config.json
{
  "adminPath": "admin",
  "resources": [
    {
      "name": "User",
      "list": { "path": "admin.userList" },
      "show": { "path": "admin.user" },
      "create": { "path": "userCreate.user" },
      "update": { "path": "userUpdate.user" },
      "delete": { "path": "userDelete.user" }
    }
  ],
  "nodeRepresentatives": ["id"],
  "collection": {
    "dataPath": "nodes",
    "totalPath": "totalCount",
    "typeNameSuffix": "Collection"
  }
}

Now, let's create a GraphQL schema file. This file defines the shape of your data:

# schema.graphql
type Query {
  admin: Admin
}

type Admin {
  user(id: ID): User
  userList: UserCollection!
}

type User {
  id: ID
  name: String
}

type UserCollection {
  nodes: [User!]
  totalCount: Int
}

input UserCreateInput {
  userInput: UserInput!
  clientMutationId: String
}

input UserInput {
  name: String
}

type UserCreatePayload {
  user: User!
  clientMutationId: String
}

type UserDeletePayload {
  user: User!
  clientMutationId: String
}

input UserDeleteInput {
  clientMutationId: String
  id: ID!
}

type UserUpdatePayload {
  user: User!
  clientMutationId: String
}

input UserUpdateInput {
  userInput: UserInput!
  clientMutationId: String
  id: ID!
}

type Mutation {
  userCreate(input: UserCreateInput!): UserCreatePayload
  userDelete(input: UserDeleteInput!): UserDeletePayload
  userUpdate(input: UserUpdateInput!): UserUpdatePayload
}

Once you've set up everything, you can run the GraphQL Code Generator. The output will be a file called queries.graphql containing the generated queries:

yarn graphql-codegen
# queries.graphql
query userList {
  admin {
    userList {
      nodes {
        id
        name
      }
      totalCount
    }
  }
}

query user($id: ID) {
  admin {
    user(id: $id) {
      id
      name
    }
  }
}

mutation userCreate($input: UserCreateInput!) {
  userCreate(input: $input) {
    user {
      id
      name
    }
  }
}

mutation userUpdate($input: UserUpdateInput!) {
  userUpdate(input: $input) {
    user {
      id
      name
    }
  }
}

mutation userDelete($input: UserDeleteInput!) {
  userDelete(input: $input) {
    user {
      id
      name
    }
  }
}