Skip to content

Tutorial is not a good introduction #1784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xixixao opened this issue May 20, 2017 · 10 comments
Closed

Tutorial is not a good introduction #1784

xixixao opened this issue May 20, 2017 · 10 comments

Comments

@xixixao
Copy link

xixixao commented May 20, 2017

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.

@xixixao
Copy link
Author

xixixao commented May 20, 2017

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.

@xixixao
Copy link
Author

xixixao commented May 20, 2017

Quick-fix suggestion: Change the start to cloning relay-examples and instead of expecting user to copy paste, just walk through the existing code.

@andyfen
Copy link

andyfen commented May 22, 2017

is ?
export const schema = ...
named
export const Schema = ...

@barbalex
Copy link

barbalex commented May 23, 2017

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 :-(

@aljones15
Copy link

there il also no example tutorial for relay modern. most example code assumes you are using relay classic

@shanewilson
Copy link

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.

@barbalex
Copy link

thanks

this here helped me over the hill: #1796 (comment)

@amkoehler
Copy link

@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.

@leebyron
Copy link
Contributor

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!

@originalhat
Copy link
Contributor

Converting to use:

export const schema = ...

in schema.js totally worked. Thanks @andyfen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants