All Projects → uesteibar → Neuron

uesteibar / Neuron

Licence: other
A GraphQL client for Elixir

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Neuron

Apollo Link
🔗 Interface for fetching and modifying control flow of GraphQL requests
Stars: ✭ 1,434 (+487.7%)
Mutual labels:  graphql, graphql-client
Client Side Graphql
Stars: ✭ 119 (-51.23%)
Mutual labels:  graphql, graphql-client
Qlens
QLens is an electron app which dynamically generates GraphQL Schemas and Mongo Schema visualization. QLens significantly cuts development time by automating the formation of their GraphQL schemas based on information fetched from their non-relational database.
Stars: ✭ 110 (-54.92%)
Mutual labels:  graphql, graphql-client
Aws Mobile Appsync Sdk Ios
iOS SDK for AWS AppSync.
Stars: ✭ 231 (-5.33%)
Mutual labels:  graphql, graphql-client
Hotchocolate
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
Stars: ✭ 3,009 (+1133.2%)
Mutual labels:  graphql, graphql-client
Angular1 Apollo
AngularJS integration for the Apollo Client
Stars: ✭ 108 (-55.74%)
Mutual labels:  graphql, graphql-client
Graphql Stack
A visual explanation of how the various tools in the GraphQL ecosystem fit together.
Stars: ✭ 117 (-52.05%)
Mutual labels:  graphql, graphql-client
Locksmith
Want to use GraphQL with Clojure/script but don't want keBab or snake_keys everywhere? Use locksmith to change all the keys!
Stars: ✭ 59 (-75.82%)
Mutual labels:  graphql, graphql-client
Gqlify
[NOT MAINTAINED]An API integration framework using GraphQL
Stars: ✭ 182 (-25.41%)
Mutual labels:  graphql, graphql-client
Modelizr
Generate GraphQL queries from models that can be mocked and normalized.
Stars: ✭ 175 (-28.28%)
Mutual labels:  graphql, graphql-client
Nuxt Graphql Request
Easy Minimal GraphQL client integration with Nuxt.js.
Stars: ✭ 85 (-65.16%)
Mutual labels:  graphql, graphql-client
Reason Urql
Reason bindings for Formidable's Universal React Query Library, urql.
Stars: ✭ 203 (-16.8%)
Mutual labels:  graphql, graphql-client
Cynic
A bring your own types GraphQL client library for Rust
Stars: ✭ 68 (-72.13%)
Mutual labels:  graphql, graphql-client
Gest
👨‍💻 A sensible GraphQL testing tool - test your GraphQL schema locally and in the cloud
Stars: ✭ 109 (-55.33%)
Mutual labels:  graphql, graphql-client
Android Okgraphql
Reactive GraphQl client for Android
Stars: ✭ 64 (-73.77%)
Mutual labels:  graphql, graphql-client
Graphql Hooks
🎣 Minimal hooks-first GraphQL client
Stars: ✭ 1,610 (+559.84%)
Mutual labels:  graphql, graphql-client
Graphql Query Test Mock
Easily mock GraphQL queries in your Relay Modern / Apollo / any-other-GraphQL-client tests.
Stars: ✭ 49 (-79.92%)
Mutual labels:  graphql, graphql-client
Apollo Angular
A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
Stars: ✭ 1,058 (+333.61%)
Mutual labels:  graphql, graphql-client
Python Graphql Client
Simple GraphQL client for Python 2.7+
Stars: ✭ 133 (-45.49%)
Mutual labels:  graphql, graphql-client
Graphql.js
A Simple and Isomorphic GraphQL Client for JavaScript
Stars: ✭ 2,206 (+804.1%)
Mutual labels:  graphql, graphql-client

neuron

Build Status Hex Version

A GraphQL client for Elixir.

Index

Installation

def deps do
  [{:neuron, "~> 5.0.0"}]
end

JSON library

Neuron defaults to using Jason for JSON encoding and decoding. To use Jason, add it to your deps

{:jason, "~> 1.1"}

It is also possible to customize which JSON library that is used

Neuron.Config.set(json_library: AnotherJSONLibrary)

Connection

Neuron defaults to using HTTP(S) protocol with HTTPoison for Connecting to GraphQL endpoint. You can however customize that behaviour, by providing custom library, which should implement Neuron.Connection behaviour:

defmodule MyConnection do
  @behaviour Neuron.Connection

  @impl Neuron.Connection
  def call(body, options) do
    IO.inspect("NEURON CALLED")
    Neuron.Connection.Http.call(body, options)
  end
end

Then set it up in config:

Neuron.Config.set(connection_module: MyConnection)

Usage

iex> Neuron.Config.set(url: "https://example.com/graph")

iex> Neuron.query("""
      {
        films {
          count
        }
      }
    """)

# Response will be:

{:ok, %Neuron.Response{body: %{"data" => %{"films" => %{ "count": 123 }}}, status_code: 200, headers: []}}

# You can also run mutations

iex> Neuron.query("""
      mutation createUser($name: String!) {
        createUser(name: $name) {
          id
          name
        }
      }
    """,
    %{name: "uesteibar"}
    )

# You can also set url and headers as shown below

iex> Neuron.query("""
      mutation createUser($name: String!) {
        createUser(name: $name) {
          id
          name
        }
      }
    """,
    %{name: "uesteibar"},
    url: "https://example.com/graph",
    headers: [authorization: "Bearer <token>"]
    )

Overriding HTTP Timeout

HTTPoison default timeout is 5000ms, in case we need to handle longer timeout, using default Neuron.Connection module, we could set connection_opts which will be passed to HTTPoison. So to override timeout to 15000ms, we could do:

iex> Neuron.Config.set(url: "https://example.com/graph", connection_opts: [recv_timeout: 15_000])

iex> Neuron.query("""
      {
        films {
          count
        }
      }
    """)

We can also set the timeout for a single request by passing the connection_opts to Neuron.query/3 instead:

iex> Neuron.query("...", %{}, connection_opts: [recv_timeout: 15_000])
More extensive documentation can be found at [https://hexdocs.pm/neuron](https://hexdocs.pm/neuron).

## Running locally

Clone the repository

```bash
git clone git@github.com:uesteibar/neuron.git

Install dependencies

cd neuron
mix deps.get

To run the tests

mix test

Style guide

Code is formatted with mix format and mix credo should not show warnings.

To format the code and run static code analysis with credo

mix format
mix credo

Contributing

Pull requests are always welcome =)

The project uses standard-changelog to update the Changelog with each commit message and upgrade the package version. For that reason every contribution should have a title and body that follows the conventional commits standard conventions (e.g. feat(connection): Make it smarter than Jarvis).

To make this process easier, you can do the following:

Install commitizen and cz-conventional-changelog globally

npm i -g commitizen cz-conventional-changelog

Save cz-conventional-changelog as default

echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

Instead of git commit, you can now run

git cz

and follow the instructions to generate the commit message.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].