json-to-graphql-query converts a JavaScript object into a GraphQL query string. v2.3.0 is current stable; released 2021, maintenance mode. Supports queries, mutations, arguments, aliases, enums, variables, directives, and inline fragments. Differentiator: fully declarative object-to-query mapping without string interpolation. Ships TypeScript types.
npm install json-to-graphql-queryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Builds a GraphQL query with arguments and an enum value from a plain object, then prints it.
Use `__on: { __typeName: 'FragmentName', ...fields }` instead of `__all_on: { ... }`.Add option `{ includeFalsyKeys: true }` to preserve fields with falsy values.Use an object with subfields for nested selections, e.g., `posts: { id: true }` instead of `posts: true`.Move `__args` to the parent field; fragments cannot have arguments.
Use `import { jsonToGraphQLQuery } from 'json-to-graphql-query'` or `const j = require('json-to-graphql-query'); j.default(...)`.Ensure the first argument to jsonToGraphQLQuery is a plain JavaScript object with a `query` or `mutation` key.
Import `{ EnumType }` from the package and use `new EnumType('VALUE')`.No dependency data recorded yet.