Hey, so I just tried quickly following the tutorial, and when I ran yarn run update-schema I got
$ babel-node ./scripts/updateSchema.js
/Users/srb/Work/Web/relay-treasurehunt/data/schema.js:10
var _nodeDefinitions = nodeDefinitions(function (globalId) {
^
ReferenceError: nodeDefinitions is not defined
at Object.<anonymous> (/Users/srb/Work/Web/relay-treasurehunt/data/schema.js:20:36)
at Module._compile (module.js:571:32)
at loader (/Users/srb/Work/Web/relay-treasurehunt/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/srb/Work/Web/relay-treasurehunt/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/srb/Work/Web/relay-treasurehunt/scripts/updateSchema.js:12:15)
I read through the old issues about the tutorial, and it doesn't seem to have changed. I have no clue what I'm doing following it (assume I have zero Relay/GraphQL experience).
The reason I got the error is because I erased the original imports. It's not clear what I am supposed to leave of the original code and I what I'm supposed to replace.
Also: it uses npm instead of yarn.
I am also getting
$ babel-node ./scripts/updateSchema.js
/Users/srb/Work/Web/relay-treasurehunt/node_modules/graphql/utilities/schemaPrinter.js:64
var directives = schema.getDirectives().filter(function (directive) {
^
TypeError: Cannot read property 'getDirectives' of undefined
at printFilteredSchema (/Users/srb/Work/Web/relay-treasurehunt/node_modules/graphql/utilities/schemaPrinter.js:64:26)
at printSchema (/Users/srb/Work/Web/relay-treasurehunt/node_modules/graphql/utilities/schemaPrinter.js:30:10)
at Object.<anonymous> (/Users/srb/Work/Web/relay-treasurehunt/scripts/updateSchema.js:50:113)
at Module._compile (module.js:571:32)
at loader (/Users/srb/Work/Web/relay-treasurehunt/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/srb/Work/Web/relay-treasurehunt/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Function.Module.runMain (module.js:605:10)
which is even more non-obvious.
Quick-fix suggestion: Change the start to cloning relay-examples and instead of expecting user to copy paste, just walk through the existing code.
is ?
export const schema = ...
named
export const Schema = ...
In real life people need to either configure an ejected create-react-app project (docs request here) or configure an existing webpack project.
How to do this is completely missing from the tutorial :-(
there il also no example tutorial for relay modern. most example code assumes you are using relay classic
In real life people need to either configure an ejected create-react-app project (docs request here) or configure an existing webpack project.
How to do this is completely missing from the tutorial :-(
This might not solve your problem but we have recently been moving a project from Classic to Modern and wrote a short post detailing all the steps we had to do:
http://softeng.oicr.on.ca/shane_wilson/2017/05/25/relay-migration/
It only goes as far as Relay-Compat because we haven't fully moved everything over to Modern yet but it should help if you have a Classic app running and want to start slowly converting containers.
thanks
this here helped me over the hill: https://github.com/facebook/relay/issues/1796#issuecomment-303432882
@shanewilson that was a very informative read, especially on how to incrementally upgrade components to relay-compat. We're not ready to upgrade yet but glad we have an idea of the commitment needed.
Sorry for the trouble, happy to see there is some resolution here.
We've improved documentation iteratively over time, but please feel free to send PRs for improvements and bug fixes to our docs whenever you find them. We appreciate it!
Converting to use:
export const schema = ...
in schema.js totally worked. Thanks @andyfen.