{"id":13508326,"url":"https://github.com/uesteibar/neuron","last_synced_at":"2025-04-08T10:18:48.677Z","repository":{"id":45325198,"uuid":"92658807","full_name":"uesteibar/neuron","owner":"uesteibar","description":"A GraphQL client for Elixir","archived":false,"fork":false,"pushed_at":"2023-02-22T09:36:12.000Z","size":178,"stargazers_count":330,"open_issues_count":5,"forks_count":36,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T08:42:12.876Z","etag":null,"topics":["elixir","elixir-lang","elixir-library","graphql","graphql-client","hex"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/neuron","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uesteibar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-05-28T12:05:16.000Z","updated_at":"2025-02-07T21:03:34.000Z","dependencies_parsed_at":"2024-01-08T19:22:11.309Z","dependency_job_id":null,"html_url":"https://github.com/uesteibar/neuron","commit_stats":{"total_commits":81,"total_committers":27,"mean_commits":3.0,"dds":0.5555555555555556,"last_synced_commit":"25ac8baf6477d88206b77321d6b7f37e49826466"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uesteibar%2Fneuron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uesteibar%2Fneuron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uesteibar%2Fneuron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uesteibar%2Fneuron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uesteibar","download_url":"https://codeload.github.com/uesteibar/neuron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247819940,"owners_count":21001394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","elixir-lang","elixir-library","graphql","graphql-client","hex"],"created_at":"2024-08-01T02:00:51.452Z","updated_at":"2025-04-08T10:18:48.655Z","avatar_url":"https://github.com/uesteibar.png","language":"Elixir","readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"assets/horizontal.png\" alt=\"neuron\" height=\"150px\"\u003e\u003c/p\u003e\n\n[![Build Status](https://github.com/uesteibar/neuron/actions/workflows/ci.yml/badge.svg)](https://github.com/uesteibar/neuron/actions/workflows/ci.yml)\n[![Hex Version](https://img.shields.io/hexpm/v/neuron.svg)](https://hex.pm/packages/neuron)\n\nA GraphQL client for Elixir.\n\n## Index\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Running Locally](#running-locally)\n- [Contributing](#contributing)\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:neuron, \"~\u003e 5.1.0\"}\n  ]\nend\n```\n\n## JSON library\n\nNeuron defaults to using Jason for JSON encoding and decoding. To use Jason, add it to your deps:\n\n```elixir\n{:jason, \"~\u003e 1.1\"}\n```\n\nIt is also possible to customize which JSON library that is used:\n\n```elixir\nNeuron.Config.set(json_library: AnotherJSONLibrary)\n```\n\n## Connection\n\nNeuron 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:\n\n```elixir\ndefmodule MyConnection do\n  @behaviour Neuron.Connection\n\n  @impl Neuron.Connection\n  def call(body, options) do\n    IO.inspect(\"NEURON CALLED\")\n    Neuron.Connection.Http.call(body, options)\n  end\nend\n```\n\nThen set it up in config:\n\n```elixir\nNeuron.Config.set(connection_module: MyConnection)\n```\n\n## Usage\n\n```elixir\niex\u003e Neuron.Config.set(url: \"https://example.com/graph\")\n\niex\u003e Neuron.query(\"\"\"\n      {\n        films {\n          count\n        }\n      }\n    \"\"\")\n```\n\nResponse will be:\n\n```elixir\n{:ok, %Neuron.Response{body: %{\"data\" =\u003e %{\"films\" =\u003e %{ \"count\": 123 }}}, status_code: 200, headers: []}}\n```\n\nYou can also run mutations:\n\n```elixir\niex\u003e Neuron.query(\"\"\"\n      mutation createUser($name: String!) {\n        createUser(name: $name) {\n          id\n          name\n        }\n      }\n    \"\"\",\n    %{name: \"uesteibar\"}\n    )\n```\n\nYou can also set url and headers as shown below:\n\n```elixir\niex\u003e Neuron.query(\"\"\"\n      mutation createUser($name: String!) {\n        createUser(name: $name) {\n          id\n          name\n        }\n      }\n    \"\"\",\n    %{name: \"uesteibar\"},\n    url: \"https://example.com/graph\",\n    headers: [authorization: \"Bearer \u003ctoken\u003e\"]\n    )\n```\n\n### Overriding HTTP Timeout\n`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:\n\n```elixir\niex\u003e Neuron.Config.set(url: \"https://example.com/graph\", connection_opts: [recv_timeout: 15_000])\n\niex\u003e Neuron.query(\"\"\"\n      {\n        films {\n          count\n        }\n      }\n    \"\"\")\n```\n\nWe can also set the timeout for a single request by passing the `connection_opts` to `Neuron.query/3` instead:\n\n```elixir\niex\u003e Neuron.query(\"...\", %{}, connection_opts: [recv_timeout: 15_000])\n```\n\nMore extensive documentation can be found at [https://hexdocs.pm/neuron](https://hexdocs.pm/neuron).\n\n## Running locally\n\nClone the repository:\n\n```bash\ngit clone git@github.com:uesteibar/neuron.git\n```\n\nInstall dependencies:\n\n```bash\ncd neuron\nmix deps.get\n```\n\nTo run the tests:\n\n```bash\nmix test\n```\n\n## Style guide\n\nCode is formatted with `mix format` and `mix credo` should not show warnings.\n\nTo format the code and run static code analysis with credo\n\n```elixir\nmix format\nmix credo\n```\n\n## Contributing\n\nPull requests are always welcome =)\n\nThe project uses [standard-changelog](https://github.com/conventional-changelog/conventional-changelog) to update the [Changelog](https://github.com/uesteibar/neuron/blob/master/CHANGELOG.md) with each commit message and upgrade the package version.\nFor that reason every contribution should have a title and body that follows the [conventional commits standard](https://conventionalcommits.org/) conventions (e.g. `feat(connection): Make it smarter than Jarvis`).\n\nTo make this process easier, you can do the following:\n\nInstall `commitizen` and `cz-conventional-changelog` globally:\n\n```bash\nnpm i -g commitizen cz-conventional-changelog\n```\n\nSave `cz-conventional-changelog` as default:\n\n```bash\necho '{ \"path\": \"cz-conventional-changelog\" }' \u003e ~/.czrc\n```\n\nInstead of `git commit`, you can now run:\n\n```\ngit cz\n```\n\nand follow the instructions to generate the commit message.\n\n## Copyright and License\n\nCopyright (c) 2017 Unai Esteibar\n\nThis software is released under the [Internet Systems Consortium License](./LICENSE.md).\n","funding_links":[],"categories":["HTTP","Elixir","Running the update"],"sub_categories":["By Popularity"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuesteibar%2Fneuron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuesteibar%2Fneuron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuesteibar%2Fneuron/lists"}