Relay-compiler-language-typescript: Support [email protected]

Created on 15 Feb 2020  Â·  7Comments  Â·  Source: relay-tools/relay-compiler-language-typescript

Update: #173 / [email protected] seems to fix the following crash. Let’s see if there is anything else to add to fully support for Relay v9 :)


TypeScriptGenerator.ts has the expectation [1] that relay-compiler/lib/transforms/ConnectionFieldTransform exists, which is no longer the case in [email protected] and has been removed in https://github.com/facebook/relay/commit/df17e69c2f07423f31d74d5c40e0b35273435688

[1] https://github.com/relay-tools/relay-compiler-language-typescript/blob/1abc3a25a78899ed21835aeaca1deb478bb67468/src/TypeScriptGenerator.ts#L16

Such change causes this error:

Error: Cannot find module 'relay-compiler/lib/transforms/ConnectionFieldTransform'
Require stack:
- /Users/jane/Coding/d5b83594/node_modules/relay-compiler-language-typescript/lib/TypeScriptGenerator.js
- /Users/jane/Coding/d5b83594/node_modules/relay-compiler-language-typescript/lib/index.js
- /Users/jane/Coding/d5b83594/node_modules/relay-compiler/bin/relay-compiler
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/jane/Coding/d5b83594/node_modules/relay-compiler-language-typescript/lib/TypeScriptGenerator.js:46:32)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)

Sample repo for testing this crash: https://github.com/wongmjane/d5b83594

Workaround

Monkeypatching TypeScriptGenerator such that the import path from relay-compiler/lib/transforms/ConnectionFieldTransform becomes relay-compiler/lib/transforms/ConnectionTransform seems to fix the crash to me

bug enhancement

Most helpful comment

@wongmjane
I cloned your repository. There was really an error using version 10. However, version 11 fixed the error!

Before (v10)
image

After (v11/12)
image

All 7 comments

Thanks for this! Think we need to work on getting #170 merged first, but afaik v9 compared to v8 didn't have that many breaking changes, so will be mostly pnp.

@maraisr I updated and landed that PR, can you take a look at the v9 upgrade (as I don’t currently use Relay)?

@wongmjane Btw can you give v11 a try? The specific change you reference should have been fixed in #170.

@alloy v9 relay works ✅ with v11 of typescript-langauge-plugin.

    "babel-plugin-relay": "9.0.0",
    "react-relay": "0.0.0-experimental-8cc94ddc",
    "relay-compiler": "9.0.0",
    "relay-config": "9.0.0",
    "relay-runtime": "9.0.0",

with that being said, I am experiencing some issues with it and our SSR/Nextjs stack. But our SPA's are working 100%. So think there must be some SSR-related apis im calling, like createOperationDescriptor that might not be there anymore. Will investigate.

But i think for the large majority, this is working. Haven't tested typing's; have it disabled for now.

@wongmjane I will however, clone your repro repo, and see how I can help!

Thanks for the update!

@wongmjane
I cloned your repository. There was really an error using version 10. However, version 11 fixed the error!

Before (v10)
image

After (v11/12)
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrtnzlml picture mrtnzlml  Â·  6Comments

RichardLindhout picture RichardLindhout  Â·  17Comments

thoughtbyte picture thoughtbyte  Â·  16Comments

cberkom picture cberkom  Â·  15Comments

artola picture artola  Â·  14Comments