Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Server #1

Closed
idkjs opened this issue Mar 12, 2019 · 6 comments
Closed

Server #1

idkjs opened this issue Mar 12, 2019 · 6 comments

Comments

@idkjs
Copy link

idkjs commented Mar 12, 2019

Hi @sainthkh. Thanks for sharing this. Learning from reading your code. Do you minde sharing the server you ran this project against?

Thank you, sir. Peace to you.

@sainthkh
Copy link
Owner

Here it is.

It used the server from official Apollo GraphQL example with a little bit of changes in schema.

Unfortunately, as this project is abandoned, it doesn't work well with this server. You might need to download this repo fully and rewind back a few commits to work it together.

Currently, I'm working on to make a new GraphQL client for ReasonML. I'm planning to write this example from scratch to make it work with that client.

I'll tell you when that new example is finished.

Until then, happy coding!

@idkjs
Copy link
Author

idkjs commented Mar 13, 2019

Nice. No problems rewinding or whatever. Mostly reading your styles so just want to see what it looks like. Thank you for sharing that code, brother.

I've already started reading through your ReasonQL repo. Having tooled around a bit in ReasonML and graphql, one thing I see that keeps coming up for me is the ability to make queries and just using the returned data as opposed to rending it to the ui. Feels kinda hacky to have to use a query component and return and empty div. I am probably missing something but there it is. We are discussing it some in the reason-apollo repo here.

The other question I seem to keep asking myself is, how do I schema stitch in ReasonML. What I want to run two queries against different endpoints? Do I have to set up two different clients?

Just some peanut gallery talk. Happy coding to you, ching-gu!

@sainthkh
Copy link
Owner

sainthkh commented Mar 14, 2019

1. About ReasonQL

After failing to create 2 GraphQL interop libraries(Reason-Relay and Apollo-ReasonML), they made me think these clients try to do too many thing. And it makes them do poor jobs.

So, I've explored a lot of other libraries and felt that cache structure shouldn't be decided by the library. Because of that, I'm trying to make a GraphQL library that do only 2 things:

  • fetch data from server.
  • decode that data and error messages from json to ReasonML record.

And as for other commonly used features like cache, fetch more, reload, auth, etc., they should be provided as an example, library users can always copy without any acknowledgement.

2. Fetching data without components.

Because of this policy, you don't need Query component to query GraphQL server in ReasonQL.

All you need are below:

module Request = ReasonQL.MakeRequest(AppQuery, {
  let url = "http://localhost:4000";
});

Request.send(Js.Dict.empty())
->Request.finished(data => {
  self.send(Fetched(data));
})

Note:

  • The API above is really experimental. It can change when I release official 0.1.0.
  • In addition to reason code above, you need compiled type code.

3. Schema Stitch.

Maybe the post below will solve your problem.

https://medium.com/open-graphql/apollo-multiple-clients-with-react-b34b571210a5

But with ReasonQL, it's a piece of cake. All you need to do is create a new Request module with new url. Then, it will work like magic.

@idkjs
Copy link
Author

idkjs commented Mar 14, 2019

Thats a big post, man. Wow. Thanks. I've considered the hacky solution of importing two different clients to for example, use yours or formidablelabs/reason-urql for querying only and keep using reason-apollo for ui queries. Don't see why that shouldnt work even if it a uninformed work around.

This is a great answer, brother. Thanks for taking the time. I already have it bookmarked.

@sainthkh
Copy link
Owner

sainthkh commented Apr 1, 2019

Hey! How are you? The first version of ReasonQL is released!

@idkjs
Copy link
Author

idkjs commented Apr 1, 2019 via email

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

No branches or pull requests

2 participants