Postgraphile: [SOLVED] relay errors when parsing postgraphql generated schema

Created on 6 Dec 2016  路  3Comments  路  Source: graphile/postgraphile

I've attached the schema, generated by postgraphql v2.0.0
schema.txt (really a .json file, but github won't let me upload it that way)

This is generated from a simple database with one table and no connections or anything. We can successfully load handwritten schemas into relay, and we can't figure out what's different about this one generated by postgraphql.

In case it's helpful, this is the error we see in babel-relay-plugin:

Error: RangeError: Maximum call stack size exceeded
    at _classCallCheck (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLAST.js:24:66)
    at new RelayQLType (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLAST.js:517:5)
    at RelayQLFragment.getType (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLAST.js:206:16)
    at shouldGenerateIdFragment (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLPrinter.js:583:17)
    at RelayQLPrinter.printFragment (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLPrinter.js:182:20)
    at /Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLPrinter.js:329:42
    at Array.forEach (native)
    at RelayQLPrinter.printSelections (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLPrinter.js:328:26)
    at RelayQLPrinter.printFragment (/Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLPrinter.js:188:31)
    at /Users/westley/code/iso-relay-test/node_modules/babel-relay-plugin/lib/RelayQLPrinter.js:329:42

Any help would be greatly appreciated!

Most helpful comment

Hi Westley,

It looks like you're using the official relay plugin which does not support our __id field, expecting instead id (which is what we had in PostGraphQL v1). To solve it you can either turn on classicIds (which will rename any id fields you have to rowId which, I have found, is rather irritating) or you can instead use the modified relay plugin (which differs by just one line of code, as Relay want to support the field to change in future themselves) which you can install from alloy:

npm install https://github.com/alloy/relay/releases/download/v0.9.3/babel-relay-plugin-0.9.3.tgz

Be warned: if you're using yarn then yarn caches based on the version ID rather than the source URL, so doing yarn add https://github.com/alloy/relay/releases/download/v0.9.3/babel-relay-plugin-0.9.3.tgz will just re-install the npm official version rather than the alloy modified version. To solve this, you can do rm -Rf node_modules/babel-relay-plugin && yarn cache clean (yes, I learned this the hard way)

Hope this helps; a PR editing the README to include this information (but better worded) would be welcome!

All 3 comments

Hi Westley,

It looks like you're using the official relay plugin which does not support our __id field, expecting instead id (which is what we had in PostGraphQL v1). To solve it you can either turn on classicIds (which will rename any id fields you have to rowId which, I have found, is rather irritating) or you can instead use the modified relay plugin (which differs by just one line of code, as Relay want to support the field to change in future themselves) which you can install from alloy:

npm install https://github.com/alloy/relay/releases/download/v0.9.3/babel-relay-plugin-0.9.3.tgz

Be warned: if you're using yarn then yarn caches based on the version ID rather than the source URL, so doing yarn add https://github.com/alloy/relay/releases/download/v0.9.3/babel-relay-plugin-0.9.3.tgz will just re-install the npm official version rather than the alloy modified version. To solve this, you can do rm -Rf node_modules/babel-relay-plugin && yarn cache clean (yes, I learned this the hard way)

Hope this helps; a PR editing the README to include this information (but better worded) would be welcome!

Thanks a ton, that version of the plugin works perfectly, we can close this or (if you'd rather) leave it open as a reminder to add that note to the README. I'll try to remember and submit a PR if I get a free moment

A feature for auto-exporting the schema was added in 3.0.0 thanks to @MaienM. We also aren鈥檛 using the name __id anymore so this issue should be solved :tada:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tazsingh picture tazsingh  路  3Comments

marshall007 picture marshall007  路  3Comments

srghma picture srghma  路  3Comments

fortm picture fortm  路  5Comments

outsidenote picture outsidenote  路  4Comments