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: https://www.tinfoilsecurity.com/blog/wormwood-graphql-testing

AstonJ

AstonJ

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

ekobi

ekobi

Very timely for me. Thanks for sharing!

Where Next?

Popular in Libraries Top

Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: https://github.com/tmbb/phoenix_ws Phoenix channels are a great...
New
engineeringdept
I’ve just released the first version of Snap, an Elasticsearch client. It borrows ideas about application structure and process managemen...
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_or...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
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
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New

Sub Categories:

We're in Beta

About us Mission Statement