Registry / api-client / superagent-graphql

superagent-graphql

JSON →
library0.1.2jsnpmunverified

A small SuperAgent plugin that wraps a GraphQL query (string + variables) into a JSON POST body. Version 0.1.2 is the latest stable release, with no update cadence. It adds a .use() middleware that sets the request body to {query, variables} and ensures the Content-Type is application/json. Unlike full GraphQL clients, this is a minimal helper for SuperAgent users who want to fire a single query without a dedicated client.

npm install superagent-graphql
INSTALL
IMPORT
SIG · SUPERAGENT-GRAPHQL
S
superagent-graphql
api-clientjavascriptv0.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ql
const ql = require('superagent-graphql');
const ql = require('superagent-graphql').default;
The package has no default export; it exports a function directly. Use require or import * as ql for ESM.
ql
import ql from 'superagent-graphql';
import { ql } from 'superagent-graphql';
ESM default import works; named import does not. The package does not ship TypeScript types.
superagent-graphql
const request = require('superagent'); const ql = require('superagent-graphql');
const { ql } = require('superagent-graphql');
The plugin does not export a named member 'ql'. Always assign the whole required module to a variable.

Shows how to send a GraphQL POST request using superagent-graphql plugin with query string and variables.

import request from 'superagent'; import ql from 'superagent-graphql'; const query = ` query GetUser($id: ID!) { user(id: $id) { name email } } `; const variables = { id: '123' }; request .post('https://api.example.com/graphql') .use(ql(query, variables)) .end((err, res) => { if (err) return console.error(err); console.log(res.body); });
Debug
Known issues
deprecatedThe package appears unmaintained (no updates in years). Latest version is 0.1.2.
fix
Consider using a modern GraphQL client or building the request manually.
affects: >=0.1.0
gotchaThe plugin always sets Content-Type to application/json, overriding any existing header.
fix
Set Content-Type after .use() if you need a different type.
affects: *
gotchaRequires superagent as a peer dependency; not installing superagent will cause runtime error.
fix
Run npm install superagent alongside superagent-graphql.
affects: *
Errors
Common errors & fixes
Cannot find module 'superagent-graphql'
Missing npm install of the package.
fix
npm install superagent-graphql
TypeError: ql is not a function
Importing incorrectly (e.g., named import instead of default).
fix
Use `import ql from 'superagent-graphql'` or `const ql = require('superagent-graphql')`
Cannot read property 'post' of undefined
Forgot to import superagent and use it as request.
fix
Add `import request from 'superagent'` at the top.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies
superagentrequiredpeer dependency; the plugin must be used with a superagent instance
Agent activity
26 hits · last 30 days
node
22
Resources
superagent-graphql — npm install superagent-graphql · libregistry