Tinfoil_Security

Tinfoil_Security

Wormwood - A Small Library to Help Test Absinthe GQL APIs

Wormwood is a small open source lib to help unit test GraphQL query documents against an Absinthe API. It requires no Plug.Conn s and removes lots of boilerplate using macros!

You can load in a GQL document file using a simple macro, and quickly execute the query against your Absinthe schema!

Simple example:

defmodule Wormwood.Test.Examples.GetUsersTest do
  use ExUnit.Case
  use Wormwood.GQLCase

  load_gql My.Absinthe.Schema, "assets/GetUsers.gql"

  describe "GetUsers.gql" do
    test "Should return a list of all the users" do
      # running the query! No conn or JSON required.
      result = query_gql(variables: %{}, context: %{:current_user => ...}) 
      assert {:ok, query_data} = result
      # ...
    end
  end
end

Quick Feature List:

  • Avoid’s boilerplate code when unit testing your Absinthe API.
  • Pass context, and variables into your query using the query_gql/1 function.
  • Supports #import statements in GQL documents for fragments!
  • Executes GQL document files and plain query strings.
  • Allows you to test the same query documents you ship to your users!
  • Provides methods to help query using a custom Absinthe pipeline.

Github: https://github.com/tinfoil/wormwood

Hex: https://hex.pm/packages/wormwood

Hexdocs: https://hexdocs.pm/wormwood/readme.html

– Tinfoil Engineering Team

(@uhrobots)

Most Liked

joshtaylor

joshtaylor

This is awesome!

One of the “problems” with testing GQL is the amount of boilerplate you have to write, mainly around syncing of queries in tests. I ended up doing similar where I included the gql file in a file and loaded it.

uhrobots

uhrobots

Thanks for the reply @joshtaylor!

I’ve also written up a blog post on the Tinfoil website with some more detailed examples and a breakdown of more advanced usage! :slight_smile:

Post: Wormwood - an Explicit Way to Test Absinthe GraphQL APIs | Black Duck Blog

AstonJ

AstonJ

Love the name as well, wormwood = Artemisia absinthium. A powerful herb used for its anti parasitic and anti-inflammatory properties :003:

Where Next?

Popular in Announcing Top

mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
kip
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir. I...
622 18934 194
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 12645 134
New
Flo0807
Hello everyone! I am excited to share our heart project Backpex with you. After building several Phoenix applications, we realized that...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement