Describe the bug
when using the plugin typescript-graphql-request as the generated graphql code contain this line
import { GraphQLClient } from 'graphql-request';
import { print } from 'graphql';
import { SdkFunctionWrapper, defaultWrapper } from '@graphql-codegen/typescript-graphql-request';
Importing from @graphql-codegen/typescript-graphql-request causes the following error because relay-compiler is used in the package and calls process.hrtime()
Error was not caught TypeError: process.hrtime is not a function
at Object.<anonymous> (VM399 _app.js:105370)
at Object.../node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js (VM399 _app.js:105478)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Object.<anonymous> (VM399 _app.js:104720)
at Object.../node_modules/relay-compiler/lib/core/CompilerContext.js (VM399 _app.js:104874)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Module.../node_modules/@graphql-toolkit/relay-operation-optimizer/index.esm.js (VM399 _app.js:20057)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Module.../node_modules/@graphql-codegen/visitor-plugin-common/index.esm.js (VM399 _app.js:16854)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Module.../node_modules/@graphql-codegen/typescript-graphql-request/index.esm.js (VM399 _app.js:16691)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Module../support/generatedGraphql.ts (VM399 _app.js:114280)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Module../support/sdk.ts (VM399 _app.js:114640)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Module../pages/_app.tsx (VM399 _app.js:114054)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at VM399 _app.js:86997
at register (VM404 main.js:3253)
at PageLoader.registerPage (VM404 main.js:3290)
at Array.register [as push] (VM404 main.js:2338)
at Object.../node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?page=%2F_app&absolutePagePath=private-next-pages%2F_app.tsx!./ (VM399 _app.js:86996)
at __webpack_require__ (VM398 webpack.js:792)
at fn (VM398 webpack.js:151)
at Object.0 (VM399 _app.js:114705)
at __webpack_require__ (VM398 webpack.js:792)
at checkDeferredModules (VM398 webpack.js:46)
That line also implies that you bundle the generator plugin as a non dev dependency, which is not true.
One solution is to remove the wrapper or move it to a different package and propmpt the user to install it as a dependency
To Reproduce
Steps to reproduce the behavior:
Use the typescript-graphql-request plugin in an app running in the browser
cc @andycmaj
Thank you for reporting this @remorses !
@andycmaj I think this is related to your changes, right?
yep. that's me. I can take this today.
Awesome! Thank you @andycmaj .
I think those interfaces could be in the generated file instead importing it?
yep i was thinking the same thing.
thanks!
sorry about that @remorses.
PR submitted
Thank you 鉂わ笍
Thanks for fixing. Is there an alpha release of the fix available?
You can use 1.13.0 for now
@sgarner You can also use 1.13.2-alpha-0799e8c0.14+0799e8c0 which has the build from current master.
Fixed in v1.13.2
@dotansimha thanks for releasing a fix for this issue! I'd like to point out that since this fix is potentially breaking as it makes changes to exported members, it should have been released as a minor version update not a patch
Tracking semver is code generator is very hard. Because of the complexity of braeking changes of both codegen code, codegen packages, codegen api and plugins generated code and plugins dependencies.
We are trying to follow semver, but it's not always easy.
In this specific case, this was a bug fix, because it worked before.
@mhagmajer
Most helpful comment
yep. that's me. I can take this today.