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

Add iml-graphql-queries crate #2236

Merged
merged 3 commits into from
Sep 12, 2020
Merged

Add iml-graphql-queries crate #2236

merged 3 commits into from
Sep 12, 2020

Conversation

jgrund
Copy link
Member

@jgrund jgrund commented Sep 11, 2020

Add a new crate, iml-graphql-queries that serves as a simple client
query builder.

It has no dependency on transport and can be used in both wasm and
native contexts.

Signed-off-by: Joe Grund jgrund@whamcloud.io


This change is Reviewable

@jgrund jgrund self-assigned this Sep 11, 2020
johnsonw
johnsonw previously approved these changes Sep 11, 2020
Copy link
Contributor

@johnsonw johnsonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be beneficial to have a run command that would make the HTTP call to the graphql endpoint with the specified query?

@jgrund
Copy link
Member Author

jgrund commented Sep 11, 2020

Do you think it would be beneficial to have a run command that would make the HTTP call to the graphql endpoint with the specified query?

No, this is purposely client agnostic so it can be used with wasm and native code, i.e. seed on the front-end and reqwest on the backend.

johnsonw
johnsonw previously approved these changes Sep 11, 2020
Add a new crate, `iml-graphql-queries` that serves as a simple client
query builder.

It has no dependency on transport and can be used in both wasm and
native contexts.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
Signed-off-by: Joe Grund <jgrund@whamcloud.io>
@jgrund jgrund requested a review from ip1981 September 11, 2020 16:03
@ip1981
Copy link
Member

ip1981 commented Sep 11, 2020

Might need a helper to decode the responses. Like

serde_json::from_value(resp.get("data").unwrap().get("createSnapshot").unwrap().clone())

ip1981
ip1981 previously approved these changes Sep 11, 2020
@jgrund
Copy link
Member Author

jgrund commented Sep 11, 2020

Might need a helper to decode the responses.

Yeah, I'll try to do that in a follow-on

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
@jgrund
Copy link
Member Author

jgrund commented Sep 11, 2020

Went ahead and implemented response support as well:

Here's how I'm creating a request in seed:

snapshot::create::build(&model.fs_name, &model.name, model.comment.as_ref(), Some(model.barrier));

let req = fetch::Request::graphql_query(&query);

orders.perform_cmd(req.fetch_json_data(|x| Msg::SnapshotCreateResp(x)));

and here's how the response looks like in msg:

SnapshotCreateResp(fetch::ResponseDataResult<Response<snapshot::create::Resp>>)

Will probably write a seed helper to collapse the nesting of that response, but that can be in another patch.

@jgrund jgrund requested a review from ip1981 September 11, 2020 18:50
@jgrund jgrund merged commit 16b27f8 into master Sep 12, 2020
@jgrund jgrund deleted the graphql-queries branch September 12, 2020 13:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants