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-httpVerified import paths — ran on the pinned version, not inferred.
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.
Migrate to a currently maintained GraphQL client (e.g., Apollo Client, Relay, Urql) and its respective transport layers.
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.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.
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.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.