Registry / http-networking / lokka-transport-http

lokka-transport-http

JSON →
library1.6.1jsnpmunverified

Lokka-transport-http provides an isomorphic HTTP transport layer designed for the Lokka GraphQL client. It facilitates sending GraphQL queries over HTTP to `graphql-express` compatible endpoints. The package's current stable version is 1.6.1, with its last release approximately 9 years ago. It supports sending custom HTTP headers and integrates with existing cookie-based authentication mechanisms, or allows for explicit `Authorization` header configuration. A key differentiator is its minimalist approach as a transport layer, allowing Lokka (a simple GraphQL client itself) to focus on query construction. The package, and the broader Lokka ecosystem, appears to be unmaintained, with no recent updates or active development. This means no new features, bug fixes, or security patches are likely. By default, it throws an error on the first GraphQL error returned by the server, but this behavior can be customized.

npm install lokka-transport-http
INSTALL
IMPORT
SIG · LOKKA-TRANSPORT-HT
L
lokka-transport-http
http-networkingjavascriptv1.6.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

HttpTransport
import HttpTransport from 'lokka-transport-http';
const HttpTransport = require('lokka-transport-http');
The package's examples use ESM syntax with a default import. For CommonJS, you would typically use `require('lokka-transport-http').default;` if using Babel or TypeScript compilation that exports a default, or simply `require('lokka-transport-http')` if it's a direct `module.exports` of the class. The incorrect `require` without `.default` is a common mistake for ESM default exports in CJS environments.

This quickstart demonstrates how to set up `lokka-transport-http` with Lokka to query a GraphQL endpoint, including an example of sending custom headers for authentication.

import HttpTransport from 'lokka-transport-http'; import Lokka from 'lokka'; // Initialize Lokka with the HTTP transport const client = new Lokka({ transport: new HttpTransport('http://graphql-swapi.parseapp.com/') }); // Send a simple GraphQL query client.query(` { allFilms { films { title } } } `).then(response => { console.log('Query successful:', JSON.stringify(response, null, 2)); }).catch(error => { console.error('Query failed:', error); }); // Example with custom headers (e.g., for authentication) const headers = { 'Authorization': `Bearer ${process.env.AUTH_TOKEN ?? ''}`, 'x-custom-header': 'some-value' }; const authenticatedClient = new Lokka({ transport: new HttpTransport('http://your-authenticated-graphql-endpoint.com/graphql', { headers }) }); authenticatedClient.query(`{ viewer { id } }`) .then(response => console.log('Authenticated query:', response)) .catch(error => console.error('Authenticated query failed:', error));
Debug
Known issues
breakingThe `lokka-transport-http` package, along with its parent `lokka` client, has been abandoned. There have been no code updates or maintenance activity for approximately 9 years, indicating a high risk of unpatched bugs, security vulnerabilities, and incompatibility with modern JavaScript environments or GraphQL server versions.
fix
Migrate to a currently maintained GraphQL client (e.g., Apollo Client, Relay, Urql) and its respective transport layers.
affects: >=1.0.0
gotchaThis package does not handle authentication logic itself. Users are responsible for managing and providing authentication credentials, typically via custom HTTP headers (e.g., `Authorization`) or relying on existing cookie-based authentication mechanisms.
fix
Manually add an `Authorization` header to the `HttpTransport` options object (e.g., `{ headers: { 'Authorization': 'Bearer YOUR_TOKEN' } }`) or ensure your client environment provides appropriate cookies for CORS requests.
affects: >=1.0.0
gotchaBy default, `lokka-transport-http` will throw a new `Error` object using only the *first* GraphQL error encountered in the response. This may hide other errors present in the GraphQL response array.
fix
Implement a custom `handleErrors` function in the `HttpTransport` options to process the full array of GraphQL errors according to your application's needs. Refer to `lib/index.js` in the package source for the default implementation example.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: lokka_transport_http_1.default is not a constructor
This error often occurs when attempting to import `HttpTransport` using CommonJS `require()` in a way that expects a direct default export, but the transpiled output puts the default export under a `.default` property.
fix
If using CommonJS, adjust the import to `const HttpTransport = require('lokka-transport-http').default;` or ensure your build system is configured for proper interoperability between ESM and CJS.
Error: GraphQL Error: [message from server]
The default error handling strategy of `lokka-transport-http` is to throw an `Error` object containing the message of the first GraphQL error returned by the server. This indicates that the GraphQL query itself resulted in server-side errors.
fix
Catch the error in your `.catch()` block and inspect the error object. For more granular control or to handle multiple GraphQL errors, provide a custom `handleErrors` function in the `HttpTransport` constructor options.
Upgrade
Version history
1.6.1latest on npm
Audit
Dependencies
lokkarequiredThis package is an HTTP transport layer specifically built for the Lokka GraphQL client and requires it as a peer dependency.
Agent activity
2 hits · last 30 days
node
2
Resources
lokka-transport-http — npm install lokka-transport-http · libregistry