{"id":25650,"library":"gotql","title":"GotQL","description":"GotQL v2.2.0 is a Node.js library that allows you to write GraphQL queries as JavaScript objects instead of strings, wrapping the Got HTTP client. It acts as a transpiler, converting JSON query definitions into proper GraphQL strings and sending them via HTTP. Key differentiators include built-in HTTP client (Got v11+), support for fragments, variables, enums via template literal helper, and nested fields. Release cadence: infrequent, last release Apr 2022. Requires Node >=18 and ESM.","status":"maintenance","version":"2.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/khaosdoctor/gotql","tags":["javascript","graphql","query","framework","serverside","graph","post","typescript"],"install":[{"cmd":"npm install gotql","lang":"bash","label":"npm"},{"cmd":"yarn add gotql","lang":"bash","label":"yarn"},{"cmd":"pnpm add gotql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"HTTP client for making GraphQL requests","package":"got","optional":false}],"imports":[{"note":"ESM-only since v2.2.0, no default export in CJS","wrong":"const gotql = require('gotql')","symbol":"default","correct":"import gotql from 'gotql'"},{"note":"Named export, works in ESM only","wrong":"const { query } = require('gotql')","symbol":"query","correct":"import { query } from 'gotql'"},{"note":"Named export, not default","wrong":"import mutation from 'gotql'","symbol":"mutation","correct":"import { mutation } from 'gotql'"}],"quickstart":{"code":"import gotql from 'gotql';\n\nconst query = {\n  operation: {\n    name: 'users',\n    fields: ['id', 'name', 'email']\n  }\n};\n\nconst options = {\n  headers: {\n    Authorization: `Bearer ${process.env.API_KEY ?? ''}`\n  }\n};\n\ntry {\n  const response = await gotql.query('https://api.example.com/graphql', query, options);\n  console.log(response.data);\n} catch (err) {\n  console.error(err);\n}","lang":"typescript","description":"Shows basic usage with ESM import, constructing a JSON query object and using the query() function with an authorization header."},"warnings":[{"fix":"Use import instead of require, or downgrade to v2.0.8 if CJS required","message":"ESM-only since v2.2.0; require() will fail with ERR_REQUIRE_ESM","severity":"breaking","affected_versions":">=2.2.0"},{"fix":"Create a new object or deep clone before modifying","message":"Modifying the query object after passing to query() may cause unexpected behavior due to mutation","severity":"gotcha","affected_versions":"*"},{"fix":"Refer to Got v11 documentation for options like http2, timeout, etc.","message":"Got v11 is used; older Got v10 options may not work","severity":"deprecated","affected_versions":">=2.2.0"},{"fix":"Upgrade to v2.0.8 or later","message":"Array arguments with more than one item may cause issues prior to v2.0.8","severity":"gotcha","affected_versions":"<2.0.8"},{"fix":"Upgrade to v2.0.5 or later","message":"Falsy variables (0, false, null) treated as undefined prior to v2.0.5","severity":"gotcha","affected_versions":"<2.0.5"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Switch to import syntax: import gotql from 'gotql'","cause":"GotQL v2.2.0 is ESM-only, but you are using require()","error":"ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/gotql/index.js from /path/to/yourfile.js not supported."},{"fix":"Use import gotql from 'gotql' or destructure: import { query } from 'gotql'","cause":"Using default import with CJS require; the module is ESM","error":"TypeError: gotql.query is not a function"},{"fix":"Ensure query object has structure: { operation: { name: 'operationName', fields: [...] } }","cause":"Query object is missing the operation property or it's malformed","error":"Error: Invalid query: \"operation\" field required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}