K6: error trying to import apollo client

Created on 13 Mar 2019  路  4Comments  路  Source: loadimpact/k6

I'm experimenting with load testing a GraphQL server and would like to pull in the apollo client.

I've generated a browerfied version with:

browserify node_modules/apollo-client/bundle.cjs.js -s apolloClient > imports/apollo-client.js

the script is:

import http from "k6/http"; import { sleep } from "k6"; import {apollo} from '../imports/apollo-client.js' export default function() { console.log(apollo) http.get("http://test.loadimpact.com"); sleep(1); };
The error is:

time="2019-03-13T15:33:13Z" level=error msg="TypeError at /src/imports/apollo-client.js:4954:84(31)"

help wanted js-compat

Most helpful comment

Agreed. I am able to test the GraphQL end point effectively just by posting and have found no need for the Apollo client. Thanks for the reply.

All 4 comments

I looked into it and it is this __extends method of tslib that is giving us trouble but I can't understand why, maybe you can rewrite it to something else that the goja (the k6 JS VM) will understand. Unfortunately I couldn't figure it out :(

Thanks for looking into it. I'll try posting directly to the apollo server without the importing the apollo client for now. (https://www.apollographql.com/docs/apollo-server/requests.html ) Importing the client would have been nice because the code would be very similar to the client I'm emulating and it would have been simpler to write.

I tried to reproduce this, given the recent JS-related changes in k6, but hit some browserify issues:

Error: Can't walk dependency graph: Cannot find module 'graphql/language/visitor' from './node_modules/apollo-client/bundle.cjs.js'

In any case, given that apollo seems to require making HTTP requests, it would have never worked in k6 without a big shim to translate its HTTP calls to the k6 API. So, I'll close this, but please comment here if you disagree and I'll reopen it (or open a new reproducible issue).

Agreed. I am able to test the GraphQL end point effectively just by posting and have found no need for the Apollo client. Thanks for the reply.

Was this page helpful?
0 / 5 - 0 ratings