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

hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
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
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
riverrun
I’ve just released version 3 of Comeonin, a password hashing library. The following small changes have been made: changes to the NIF c...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
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
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Sub Categories:

We're in Beta

About us Mission Statement