Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gen1321/simple_graphql_client
SimpleGraphqlClient is a graphql client, focused on simplicity and ease of use.
https://github.com/gen1321/simple_graphql_client
absinthe absinthe-graphql elixir elixir-lang elixir-library graphql graphql-client hex
Last synced: about 1 month ago
JSON representation
SimpleGraphqlClient is a graphql client, focused on simplicity and ease of use.
- Host: GitHub
- URL: https://github.com/gen1321/simple_graphql_client
- Owner: gen1321
- License: mit
- Created: 2018-10-14T20:56:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-12T20:09:28.000Z (over 4 years ago)
- Last Synced: 2024-09-28T21:43:02.328Z (about 2 months ago)
- Topics: absinthe, absinthe-graphql, elixir, elixir-lang, elixir-library, graphql, graphql-client, hex
- Language: Elixir
- Size: 42 KB
- Stars: 19
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleGraphqlClient
Simple Graphql client for elixir!## Why
Q: There is a lot of others GraphQL clients for elixir, why creating another one.A: Because some of them wants you to interpolate variables directly into your query string, and IMHO that is not best approach, some of them are too complicated for just pick them up. And some of them extremely cool like Maple but do not fit into general usage.
## Usage
### Query/Mutation example
```elixir
iex>
query = "query users($name: String){users(name: $name){name}}"
SimpleGraphqlClient.graphql_request(query, %{name: "Boris"})
# Will produce
{:ok,
%SimpleGraphqlClient.Response{
body: {:ok, %{"data" => %{"users" => []}}},
headers: [],
status_code: 200
}
}
```### Subscription example
```elixir
sub_query = "
subscription testsub {
userAdded{
}
}
"
SimpleGraphqlClient.absinthe_subscribe(sub_query, %{}, &IO.inputs/1)# Will produce
%{"userAdded" => %{"email" => "[email protected]"}}
```## More examples
You can find more examples in `test_app/test/graphql` folder## Configuration
For configuration i suggest to write your own wrappers of &graphql_request/3 or any subscribe function. If you want to pass Authorization parametrs to WS connection, please encode them into url.## Installation
```elixir
def deps do
[
{:simple_graphql_client, "~> 0.2.0"}
]
end
```## Roadmap
* Add support for subscribtion(50% done, absinthe subscriptions already here)
* Better Dialyzer
* CI/Test coverege
PRs are WELCOMEDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/simple_graphql_client](https://hexdocs.pm/simple_graphql_client).