lvarayut / relay-fullstack

:point_up::running: Modern Relay Starter Kit - Integrated with Relay, GraphQL, Express, ES6/ES7, JSX, Webpack, Babel, Material Design Lite, and PostCSS
https://lvarayut.github.io/relay-fullstack/
MIT License
985 stars 126 forks source link

Generate Schema from remote server #24

Closed agungsb closed 8 years ago

agungsb commented 8 years ago

I'm recently playing with this relay-fullstack. I wonder if I can make a request to remove server (currently, server and client are running in localhost).

For example, my server is in http://127.0.0.1:8529/_db/_system/api/graphql (I'm using ArangoDB for the backend). I've read Relay's documentation which says that I can achieve it with the following:

Relay.injectNetworkLayer( new Relay.DefaultNetworkLayer('http://127.0.0.1:8529/_db/_system/api/graphql', { fetchTimeout: 30000, // Timeout after 30s. retryDelays: [5000], // Only retry once after a 5s delay. }) );

Everything should be fine. But every time I run the app, there's always an error that demands me to update the schema. In my case:

Uncaught Error: GraphQL validation error``Cannot query field "human" on type "User".``in fileC:/xampp/htdocs/relay-starwars/client/components/Feature/FeatureContainer.js. Try updating your GraphQL schema if an argument/field/type was recently added.

How do I solve this? Is it possible to generate/update the schema from a remote server? I'm sure that the backend is already settled and running fine.. *checked with GraphiQL and Postman

Any thoughts?

lvarayut commented 8 years ago

Where do you define your GraphQL types and schema?

agungsb commented 8 years ago

Based on default project structure, it is located inside /server/data/ folder.

lvarayut commented 8 years ago

Are you also running your GraphQL HTTP Server at http://127.0.0.1:8529/_db/_system/api/graphql? Relay currently sends a request to your specified endpoint. so, your endpoint needs to handle a graphql request and send back some response to Relay. If you have set it up, please provide your code and the way you tested on Postman and GraphiQL.

agungsb commented 8 years ago

Hi, @lvarayut . Sorry for the late reply. I read your comment here. You said that you're using ArangoDB for backend and Relay for the frontend.

Well, this is the situation that I am facing right now. Any thoughts about the best approach or best practice to achieve it (at least, I would like to know how you achieved it)? Or there will be support for ArangoDB in the future?

Thanks.. :)

lvarayut commented 8 years ago

You need to use graphql-sync to define types and to generate schema.json in your Foxx app, and then, provide an api in order to pass the compiled schema.json back to your Relay app. See this issue on graphql-sync.

I'm going to close this issue since it seems to be not related to Relay Fullstack. Please feel free to continue the discussion here if you had more question.

lvarayut commented 8 years ago

@agungsb, I found a good answer on this Stack Overflow question that might be useful to you.