{"id":16428,"library":"lokka-transport-http","title":"Lokka HTTP Transport","description":"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.","status":"abandoned","version":"1.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/kadirahq/lokka-transport-http","tags":["javascript","lokka","transport","http"],"install":[{"cmd":"npm install lokka-transport-http","lang":"bash","label":"npm"},{"cmd":"yarn add lokka-transport-http","lang":"bash","label":"yarn"},{"cmd":"pnpm add lokka-transport-http","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is an HTTP transport layer specifically built for the Lokka GraphQL client and requires it as a peer dependency.","package":"lokka","optional":false}],"imports":[{"note":"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.","wrong":"const HttpTransport = require('lokka-transport-http');","symbol":"HttpTransport","correct":"import HttpTransport from 'lokka-transport-http';"}],"quickstart":{"code":"import HttpTransport from 'lokka-transport-http';\nimport Lokka from 'lokka';\n\n// Initialize Lokka with the HTTP transport\nconst client = new Lokka({\n  transport: new HttpTransport('http://graphql-swapi.parseapp.com/')\n});\n\n// Send a simple GraphQL query\nclient.query(`\n    {\n      allFilms {\n        films {\n          title\n        }\n      }\n    }\n`).then(response => {\n    console.log('Query successful:', JSON.stringify(response, null, 2));\n}).catch(error => {\n    console.error('Query failed:', error);\n});\n\n// Example with custom headers (e.g., for authentication)\nconst headers = {\n    'Authorization': `Bearer ${process.env.AUTH_TOKEN ?? ''}`,\n    'x-custom-header': 'some-value'\n};\nconst authenticatedClient = new Lokka({\n    transport: new HttpTransport('http://your-authenticated-graphql-endpoint.com/graphql', { headers })\n});\n\nauthenticatedClient.query(`{ viewer { id } }`)\n  .then(response => console.log('Authenticated query:', response))\n  .catch(error => console.error('Authenticated query failed:', error));","lang":"javascript","description":"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."},"warnings":[{"fix":"Migrate to a currently maintained GraphQL client (e.g., Apollo Client, Relay, Urql) and its respective transport layers.","message":"The `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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"By 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: lokka_transport_http_1.default is not a constructor"},{"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.","cause":"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.","error":"Error: GraphQL Error: [message from server]"}],"ecosystem":"npm"}