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 🙏

© 2025 – Pkg Stats / Ryan Hefner

normalize-graphql-query

v1.4.0

Published

[![Build](https://github.com/cnwangjie/normalize-graphql-query/actions/workflows/build.yaml/badge.svg)](https://github.com/cnwangjie/normalize-graphql-query/actions/workflows/build.yaml) [![npm](https://img.shields.io/npm/v/normalize-graphql-query)](https

Downloads

116

Readme

Normalize GraphQL Query

Build npm

Usage

Apollo Server

+ import { apolloPlugin as normalize } from 'normalize-graphql-query'

  export const createServer = () => {
    const schema = makeExecutableSchema({ typeDefs, resolvers })
    const server = new ApolloServer({
      schema,
      plugins: [
+      normalize(), // <-- just add this plugin
      ],
    })
    return { server, schema }
  }

Other GraphQL Server

import {
  normalizeGraphQLQuery,
  transformGraphQLResponse,
} from 'normalize-graphql-query'

// normalize the query & variables of the request
const normalized = normalizeGraphQLQuery({
  query,
  variables,
})

// then you can use it to execute the query
const response = await server.executeOperation(normalized)

// transform the response data to satisfy the original query
const data = transformGraphQLResponse(normalized, response.data)

Why you need it

Consider you have a GraphQL API like this.

But sometimes you will get some queries like this.

query ($_1kjtl64174kta: ID!) {
  generationModelVersionquery_14tc0yqlfqwfc: generationModelVersion(id: $_1kjtl64174kta) {
    __typename
    idgenerationModelVersion_42c46wm2gnbc: id
    modelIdgenerationModelVersion_42c46wm2gnbc: modelId
    modelgenerationModelVersion_42c46wm2gnbc: model {
      __typename
      extragenerationModel_42c46wm2gnbc: extra
      idgenerationModel_42c46wm2gnbc: id
      idgenerationModel_42c46wm2gnbc: id
      authorgenerationModel_42c46wm2gnbc: author {
        __typename
        profilesuser_42c46wm2gnbc: profiles
        iduser_42c46wm2gnbc: id
        usernameuser_42c46wm2gnbc: username
        displayNameuser_42c46wm2gnbc: displayName
        avatarMediauser_42c46wm2gnbc: avatarMedia {
          __typename
          idmedia_42c46wm2gnbc: id
          typemedia_42c46wm2gnbc: type
          widthmedia_42c46wm2gnbc: width
          heightmedia_42c46wm2gnbc: height
          imageTypemedia_42c46wm2gnbc: imageType
          urlsmedia_42c46wm2gnbc: urls {
            __typename
            variantimageUrl_42c46wm2gnbc: variant
            urlimageUrl_42c46wm2gnbc: url
          }
        }
      }
      # ...

WTF

After you normalize it, you will get a query like this.

query task($id: ID!) {
  task(id: $id) {
    __typename
    outputs
    parameters
    id
    priority
    artworkId
    media {
      __typename
      id
      type
      width
      height
      imageType
      urls {
        __typename
        variant
        url
        # ...

clap

You will get the same query if their structure is the same.

License

MIT License