{"id":16793776,"url":"https://github.com/cnwangjie/normalize-graphql-query","last_synced_at":"2026-01-28T00:36:07.900Z","repository":{"id":175904451,"uuid":"493526041","full_name":"cnwangjie/normalize-graphql-query","owner":"cnwangjie","description":"Make GraphQL queries normalized, observable and auditable.","archived":false,"fork":false,"pushed_at":"2023-09-21T17:40:00.000Z","size":769,"stargazers_count":3,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-28T09:14:05.670Z","etag":null,"topics":["apollo","graphql","normalize"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/normalize-graphql-query","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnwangjie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-18T05:48:10.000Z","updated_at":"2025-05-15T17:58:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"b62ef393-38f3-46e1-b0cb-e389621f14cc","html_url":"https://github.com/cnwangjie/normalize-graphql-query","commit_stats":null,"previous_names":["cnwangjie/normalize-graphql-query"],"tags_count":0,"template":false,"template_full_name":"cnwangjie/ts-mod","purl":"pkg:github/cnwangjie/normalize-graphql-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnwangjie%2Fnormalize-graphql-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnwangjie%2Fnormalize-graphql-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnwangjie%2Fnormalize-graphql-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnwangjie%2Fnormalize-graphql-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnwangjie","download_url":"https://codeload.github.com/cnwangjie/normalize-graphql-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnwangjie%2Fnormalize-graphql-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28829511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","graphql","normalize"],"created_at":"2024-10-13T08:50:19.588Z","updated_at":"2026-01-28T00:36:07.680Z","avatar_url":"https://github.com/cnwangjie.png","language":"TypeScript","readme":"# Normalize GraphQL Query\n\n[![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)\n[![npm](https://img.shields.io/npm/v/normalize-graphql-query)](https://www.npmjs.com/package/normalize-graphql-query)\n\n## Usage\n\n**Apollo Server**\n\n```diff\n+ import { apolloPlugin as normalize } from 'normalize-graphql-query'\n\n  export const createServer = () =\u003e {\n    const schema = makeExecutableSchema({ typeDefs, resolvers })\n    const server = new ApolloServer({\n      schema,\n      plugins: [\n+      normalize(), // \u003c-- just add this plugin\n      ],\n    })\n    return { server, schema }\n  }\n```\n\n**Other GraphQL Server**\n\n```ts\nimport {\n  normalizeGraphQLQuery,\n  transformGraphQLResponse,\n} from 'normalize-graphql-query'\n\n// normalize the query \u0026 variables of the request\nconst normalized = normalizeGraphQLQuery({\n  query,\n  variables,\n})\n\n// then you can use it to execute the query\nconst response = await server.executeOperation(normalized)\n\n// transform the response data to satisfy the original query\nconst data = transformGraphQLResponse(normalized, response.data)\n```\n\n## Why you need it\n\nConsider you have a GraphQL API like this.\n\nBut sometimes you will get some queries like this.\n\n```graphql\nquery ($_1kjtl64174kta: ID!) {\n  generationModelVersionquery_14tc0yqlfqwfc: generationModelVersion(id: $_1kjtl64174kta) {\n    __typename\n    idgenerationModelVersion_42c46wm2gnbc: id\n    modelIdgenerationModelVersion_42c46wm2gnbc: modelId\n    modelgenerationModelVersion_42c46wm2gnbc: model {\n      __typename\n      extragenerationModel_42c46wm2gnbc: extra\n      idgenerationModel_42c46wm2gnbc: id\n      idgenerationModel_42c46wm2gnbc: id\n      authorgenerationModel_42c46wm2gnbc: author {\n        __typename\n        profilesuser_42c46wm2gnbc: profiles\n        iduser_42c46wm2gnbc: id\n        usernameuser_42c46wm2gnbc: username\n        displayNameuser_42c46wm2gnbc: displayName\n        avatarMediauser_42c46wm2gnbc: avatarMedia {\n          __typename\n          idmedia_42c46wm2gnbc: id\n          typemedia_42c46wm2gnbc: type\n          widthmedia_42c46wm2gnbc: width\n          heightmedia_42c46wm2gnbc: height\n          imageTypemedia_42c46wm2gnbc: imageType\n          urlsmedia_42c46wm2gnbc: urls {\n            __typename\n            variantimageUrl_42c46wm2gnbc: variant\n            urlimageUrl_42c46wm2gnbc: url\n          }\n        }\n      }\n      # ...\n\n```\n\n![WTF](https://media0.giphy.com/media/4cQSQYz0a9x9S/giphy.gif?cid=ecf05e47f8skucucfp3ytg9b1v8qf0qg3g5k0yffxc3d0u4j\u0026ep=v1_gifs_search\u0026rid=giphy.gif\u0026ct=g)\n\nAfter you normalize it, you will get a query like this.\n\n```graphql\nquery task($id: ID!) {\n  task(id: $id) {\n    __typename\n    outputs\n    parameters\n    id\n    priority\n    artworkId\n    media {\n      __typename\n      id\n      type\n      width\n      height\n      imageType\n      urls {\n        __typename\n        variant\n        url\n        # ...\n```\n\n![clap](https://media3.giphy.com/media/1236TCtX5dsGEo/giphy.gif?cid=ecf05e4704julcaak3xc1mwxtj7tinh7ppewjk1xezyx4k4p\u0026ep=v1_gifs_search\u0026rid=giphy.gif\u0026ct=g)\n\nYou will get the same query if their structure is the same.\n\n## License\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnwangjie%2Fnormalize-graphql-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnwangjie%2Fnormalize-graphql-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnwangjie%2Fnormalize-graphql-query/lists"}