Giter Site home page Giter Site logo

gql's Introduction

GQL

Package Documentation CI

Simple GraphQL client for Elixir.

Installation

The package can be installed by adding gql to your list of dependencies in mix.exs:

def deps do
  [
    {:gql, "~> 0.6.0"}
  ]
end

Usage

url = "https://api.spacex.land/graphql/"

# List SpaceX launches
GQL.query("query Launches { launches { id } }", url: url)

# Get SpaceX launch by ID
GQL.query("query Launch($launch_id: ID!) { launch(id: $launch_id) { details } }",
  url: url,
  variables: [launch_id: "9"]
)

See GQL docs for details.

Fragments

This library does not support GraphQL fragments. I'm open to pull-requests but this is not something that is a priority to me.

Alternatives

Please submit an issue or pull-request if you know of any other GraphQL client libraries for Elixir.

The README indicates this project is not ready for use and it hasn't seen commits since 2019.

Neuron is a great library and I have successfully used it in production. But there are a few issues that have lead me to create GQL instead:

  • There are serious problems in how fragments are handled in Neuron.Fragment. All fragments are registered either globally using Application.put_env/3 or per-process using Process.put/2. It would be easy for two different client libraries to overwrite each others' fragments and cause surprising and hard to find bugs.
  • Neuron does not always return descriptive errors. For example, when an API endpoint returns an HTTP status of 500 with HTML in the body (like Shopify) then Neuron.JSONParseError is returned as opposed to an error that indicates 500 error. This makes the errors more cryptic and harder for apps like sentry.io to categorize.
  • I prefer finch over httpoison.

gql's People

Contributors

balexand avatar kianmeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.