Skip to content
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

Document injected data format. #30

Closed
frederikcreemers opened this issue Apr 5, 2016 · 5 comments
Closed

Document injected data format. #30

frederikcreemers opened this issue Apr 5, 2016 · 5 comments

Comments

@frederikcreemers
Copy link

Hi,

I'd like to use just the client-side part of this. My app is built using Django, and I'd prefer not to add anything that requires javascript evaluation on the server. I can probably generate the json in Python. But in order to do that I'd like to know how the data is structured.

@hellatan
Copy link

@bigblind if you're going to be rendering this client-side only, you should be able to use the regular react-relay module.

@thelordoftheboards
Copy link

@bigblind naturally, it will become your responsibility as a developer to provide all the correct data that Relay would request if it was rendered on the server, and update the data whenever you update the components, etc. Should not be too hard, just something to keep in mind when you're making changes. I am not sure if I am reading the change logs correctly, but it seems like with 0.8 this is possible just with react-relay as @hellatan suggested?

@frederikcreemers
Copy link
Author

@thelordoftheboards What API method on relay would I call then to inject the data? I asked about this in the Relay issue tracker, and they directed me here, and it seems pretty clear that I need the injectPreparedData method that isomorphic-relay provides.

@hellatan
Copy link

@bigblind ok, i think i see what you mean based on your comment in your relay comment. As you mentioned, i would imagine you would use the injectPreparedData method in your client-side entry file and you would be responsible for passing the json to that method.

You'd obviously need to mimic the data structure that that method requires, which looks something like this:

[ { query:
     { calls: [],
       children: [Object],
       directives: [],
       fieldName: 'viewer',
       isDeferred: false,
       kind: 'Query',
       metadata: [Object],
       name: 'CollectionsLandingQueryRoute',
       type: 'Viewer' },
    result: { viewer: [Object] } } ]

Hypothetically it sounds like it could work, but I'm pretty new to isomorphic react (as in started using it the past couple days) so I'm not 100% sure what the inner workings of injectPreparedData is doing.

The reason why there's query.result.viewer is due to this bug in relay.

@denvned
Copy link
Owner

denvned commented Apr 22, 2016

The data is an array of { query: ConcreteQuery, response: Object }.

The shape of ConcreteQuery is described here. And the response is just a response of GraphQL server for that query. But note that ConcreteQuery is not a part of Relay public API, and can be changed or removed in any release. Also, isomorphic-relay might not use ConcreteQuery in future versions, but take advantage of GraphMode instead (when it is ready).

@denvned denvned closed this as completed Apr 22, 2016
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

4 participants