在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):uesteibar/neuron开源软件地址(OpenSource Url):https://github.com/uesteibar/neuron开源编程语言(OpenSource Language):Elixir 100.0%开源软件介绍(OpenSource Introduction):A GraphQL client for Elixir. IndexInstallationdef deps do
[
{:neuron, "~> 5.0.0"}
]
end JSON libraryNeuron 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) ConnectionNeuron 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) Usageiex> 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
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 iex> Neuron.query("...", %{}, connection_opts: [recv_timeout: 15_000]) More extensive documentation can be found at https://hexdocs.pm/neuron. Running locallyClone the repository: git clone [email protected]:uesteibar/neuron.git Install dependencies: cd neuron
mix deps.get To run the tests: mix test Style guideCode is formatted with To format the code and run static code analysis with credo mix format
mix credo ContributingPull 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. To make this process easier, you can do the following: Install npm i -g commitizen cz-conventional-changelog Save echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc Instead of
and follow the instructions to generate the commit message. Copyright and LicenseCopyright (c) 2017 Unai Esteibar This software is released under the Internet Systems Consortium License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论