Relay-compiler-language-typescript: Version 9 incompatible with relay-compiler version 7?

Created on 23 Oct 2019  路  7Comments  路  Source: relay-tools/relay-compiler-language-typescript

Most helpful comment

All 7 comments

@types/relay-compiler needs to be updated and add types for new files

after fixing file imports, this error will occurs

ERROR:
  Error writing modules:
  Error: Invalid AST Node: { QUERY_TYPE_KEY: Symbol(Query), MUTATION_TYPE_KEY: Symbol(Mutation), SUBSCRIPTION_TYPE_KEY: Symbol(Subsription), _baseSchema: { __validationErrors: [], extensions: undefined, astNode: [Object], extensionASTNodes: undefined, __allowedLegacyNames: [], _queryType: Root, _mutationType: null, _subscriptionType: null, _directives: [Array], _typeMap: [Object], _possibleTypeMap: {}, _implementations: [Object] }, _extendedSchema: { __validationErrors: undefined, extensions: undefined, astNode: [Object], extensionASTNodes: [], __allowedLegacyNames: [], _queryType: Root, _mutationType: null, _subscriptionType: null, _directives: [Array], _typeMap: [Object], _possibleTypeMap: {}, _implementations: [Object] }, _typeMap: {}, _fieldsMap: {}, _typeNameMap: {}, _clientIdMap: {}, _possibleTypesMap: {}, _directivesMap: {} }
at visit (/path-to-project/node_modules/graphql/language/visitor.js:236:15)
at Object.visitIR [as visit] (/path-to-project/node_modules/relay-compiler/lib/core/GraphQLIRVisitor.js:41:10)
at Object.exports.generate (/path-to-project/node_modules/relay-compiler-language-typescript/lib/TypeScriptGenerator.js:68:46)
at /path-to-project/node_modules/relay-compiler/bin/relay-compiler:11541:64
at Generator.next (<anonymous>)
at asyncGeneratorStep (/path-to-project/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/path-to-project/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
at /path-to-project/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
at new Promise (<anonymous>)
at /path-to-project/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12

the error throws from this line

const ast: ts.Statement[] = IRVisitor.visit(node, createVisitor(options));

Relay now uses its own ast so some updates are needed to use their schema helpers instead of using graphql-js.

I made the changes to the compiled files quickly just to get it working if that can help someone https://gist.github.com/janicduplessis/6c134b4c21168aa28b81e3fd818ec9bd

We'll need to update this based on the recent changes in https://github.com/facebook/relay/blob/master/packages/relay-compiler/language/javascript/RelayFlowGenerator.js and https://github.com/facebook/relay/blob/master/packages/relay-compiler/language/javascript/RelayFlowTypeTransformers.js

I guess it'll be quite a lot of work to get it relay v7 compatible. I made a fork with some of the changes here: https://github.com/sorenhoyer/relay-compiler-language-typescript - not sure I'll have time over the weekend to continue, so hopefully somebody else is working on this and will beat me to it :D

Thanks for all jumping on this, people, really happy with the community effort 馃檶

Fixed by #155

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thoughtbyte picture thoughtbyte  路  3Comments

wongmjane picture wongmjane  路  7Comments

alloy picture alloy  路  27Comments

janicduplessis picture janicduplessis  路  3Comments

steida picture steida  路  10Comments