{"id":13833594,"url":"https://github.com/rzane/absinthe_conn_test","last_synced_at":"2026-03-01T04:35:20.169Z","repository":{"id":56841788,"uuid":"312497516","full_name":"rzane/absinthe_conn_test","owner":"rzane","description":"Helpful utilities for testing your GraphQL API","archived":false,"fork":false,"pushed_at":"2020-11-13T18:10:42.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-01T17:31:29.449Z","etag":null,"topics":["absinthe","elixir","graphql","phoenix","testing","uploads"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/absinthe_conn_test","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rzane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-13T06:59:01.000Z","updated_at":"2020-11-17T10:53:43.000Z","dependencies_parsed_at":"2022-08-29T07:42:16.277Z","dependency_job_id":null,"html_url":"https://github.com/rzane/absinthe_conn_test","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rzane/absinthe_conn_test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzane%2Fabsinthe_conn_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzane%2Fabsinthe_conn_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzane%2Fabsinthe_conn_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzane%2Fabsinthe_conn_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rzane","download_url":"https://codeload.github.com/rzane/absinthe_conn_test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzane%2Fabsinthe_conn_test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29960253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["absinthe","elixir","graphql","phoenix","testing","uploads"],"created_at":"2024-08-04T12:00:51.561Z","updated_at":"2026-03-01T04:35:20.153Z","avatar_url":"https://github.com/rzane.png","language":"Elixir","funding_links":[],"categories":["Running the update"],"sub_categories":["By Popularity"],"readme":"# Absinthe.ConnTest\n\nThis package makes it really convenient to execute GraphQL queries and mutations\nagainst your Phoenix Endpoint.\n\nExecuting queries as HTTP requests helps to ensure that your application behaves\nthe same way under test as it does under normal circumstances.\n\n## Installation\n\nThe package can be installed by adding `absinthe_conn_test` to your list of\ndependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:absinthe_conn_test, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Setup\n\nYou'll probably want to import this module in your `ConnCase`.\n\n```elixir\n# test/support/conn_case.ex\n\ndefmodule MyAppWeb.ConnCase do\n  use ExUnit.CaseTemplate\n\n  using do\n    quote do\n      # ...etc, etc\n\n      # Import this library\n      import Absinthe.ConnTest\n\n      # The default endpoint for testing\n      @endpoint MyAppWeb.Endpoint\n\n      # The default URL for your GraphQL API\n      @graphql \"/graphql\"\n    end\n  end\n\n  # ... etc, etc\nend\n```\n\n## Testing\n\nA simple test might look something like this:\n\n```elixir\ndefmodule MyAppWeb.Schema.UsersTest do\n  use MyAppWeb.ConnCase\n\n  @say_hello \"\"\"\n  query SayHello($name: String!) {\n    hello(name: $name)\n  }\n  \"\"\"\n\n  test \"hello\", %{conn: conn} do\n    assert {:ok, %{\"hello\" =\u003e \"Hello, Ray!\"}} =\n            graphql(conn, @say_hello, name: \"Ray\")\n  end\nend\n```\n\n### Importing queries\n\nYuck, it's kind of annoying to write your queries in your test file. Let's move\nthem to dedicated `.graphql` file:\n\n```graphql\n# test/fixtures/queries.graphql\n\nquery SayHello($name: String!) {\n  hello(name: $name)\n}\n```\n\nNow, you can import those queries, and they'll become test functions!\n\n```elixir\ndefmodule MyAppWeb.Schema.UsersTest do\n  use MyAppWeb.ConnCase\n\n  import_queries \"test/fixtures/queries.graphql\"\n\n  test \"hello\", %{conn: conn} do\n    assert {:ok, %{\"hello\" =\u003e \"Hello, Ray!\"}} = say_hello(conn, name: \"Ray\")\n  end\nend\n```\n\nNote that in the example above the `SayHello` query became a function `say_hello`.\n\n### Errors\n\nErrors are returned in a concise format:\n\n```elixir\ntest \"produces an error message\", %{conn: conn} do\n  assert {:error, [\"is invalid\"]} = create_user(conn, data: %{})\nend\n```\n\nIf your error contains extensions, it'll look like this:\n\n```elixir\ntest \"produces an error message with extensions\", %{conn: conn} do\n  assert {:error, [{\"is invalid\", %{\"code\" =\u003e \"VALIDATION_ERROR\"}}]} =\n           create_user(conn, data: %{})\nend\n```\n\n### Fragments\n\nYup, they're supported too. It will also resolve `#import` expressions.\n\n```graphql\n# test/fixtures/users.graphql\n\nfragment User on User {\n  id\n  name\n}\n```\n\n```graphql\n#import \"./user.graphql\"\n\nquery ListUsers {\n  users {\n    ...User\n  }\n}\n```\n\n### File Uploads\n\nIf you attempt to send a [`%Plug.Upload{}`](https://hexdocs.pm/plug/Plug.Upload.html)\nto your API, this library will extract it for you in accordance with Absinthe's [file\nupload specification](https://hexdocs.pm/absinthe/file-uploads.html).\n\n```graphql\n# test/fixtures/queries.graphl\n\nmutation UploadImage($image: Upload!) {\n  uploadImage(image: $image)\n}\n```\n\n```elixir\nimport_queries \"test/fixtures/queries.graphql\"\n\ntest \"uploading an image\", %{conn: conn} do\n  image = %Plug.Upload{\n    filename: \"foo.png\",\n    path: \"test/fixtures/image.png\"\n  }\n\n  assert {:ok, } = upload_image(conn, image: image)\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frzane%2Fabsinthe_conn_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frzane%2Fabsinthe_conn_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frzane%2Fabsinthe_conn_test/lists"}