All Projects → vermiculus → Graphql.el

vermiculus / Graphql.el

GraphQL utilities

Programming Languages

elisp
30 projects

Projects that are alternatives of or similar to Graphql.el

Typeorm Graphql Loader
A query builder to easily resolve nested fields and relations for TypeORM-based GraphQL servers
Stars: ✭ 47 (-6%)
Mutual labels:  graphql
Umi Plugin Apollo
Apollo graphql plugin for umi
Stars: ✭ 48 (-4%)
Mutual labels:  graphql
Memrise.el
Emacs Memrise integration
Stars: ✭ 49 (-2%)
Mutual labels:  emacs
Docker Compose Mode
Major mode for editing docker-compose files
Stars: ✭ 47 (-6%)
Mutual labels:  emacs
Intero
Stars: ✭ 1,042 (+1984%)
Mutual labels:  emacs
Paredit Cheatsheet
A new, scalable source document for the Paredit Cheatsheet available as a png on the Emacs wiki
Stars: ✭ 48 (-4%)
Mutual labels:  emacs
Githunt React
[DEPRECATED] 🔃 An example app frontend built with Apollo Client and React
Stars: ✭ 1,036 (+1972%)
Mutual labels:  graphql
All The Icons.el
A utility package to collect various Icon Fonts and propertize them within Emacs.
Stars: ✭ 1,048 (+1996%)
Mutual labels:  emacs
Liberime
A emacs dynamic module provide librime bindings for emacs
Stars: ✭ 48 (-4%)
Mutual labels:  emacs
Graphql Query Test Mock
Easily mock GraphQL queries in your Relay Modern / Apollo / any-other-GraphQL-client tests.
Stars: ✭ 49 (-2%)
Mutual labels:  graphql
Semantic Graphql
Create GraphQL schemas from RDF ontologies
Stars: ✭ 47 (-6%)
Mutual labels:  graphql
Graphql Zeus
GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native
Stars: ✭ 1,043 (+1986%)
Mutual labels:  graphql
Parse Graphql
Parse GraphQL Query.
Stars: ✭ 49 (-2%)
Mutual labels:  graphql
Graphql Kr.github.io
🇰🇷 GraphQL Document in Korean
Stars: ✭ 47 (-6%)
Mutual labels:  graphql
Counsel Spotify
Control Spotify App through Emacs
Stars: ✭ 49 (-2%)
Mutual labels:  emacs
Graphql Scalars
A library of custom GraphQL Scalars for creating precise type-safe GraphQL schemas.
Stars: ✭ 1,023 (+1946%)
Mutual labels:  graphql
Aurel
Search, vote for and download AUR packages from Emacs
Stars: ✭ 48 (-4%)
Mutual labels:  emacs
Appsync Resolvers Example
Example project for AppSync, GraphQL, and AWS Lambda resolvers using Go.
Stars: ✭ 50 (+0%)
Mutual labels:  graphql
Dropwizard Graphql
Dropwizard GraphQL Bundle
Stars: ✭ 49 (-2%)
Mutual labels:  graphql
Ikeysnail
iKeySnail provides fully-configurable hardware keyboard functionalities for web browsing on iOS (iPadOS)
Stars: ✭ 48 (-4%)
Mutual labels:  emacs

GraphQL.el

MELPA Status Build Status

GraphQL.el provides a set of generic functions for interacting with GraphQL web services.

See also the following resources:

Syntax Overview

Two macros are provided to express GraphQL queries and mutations:

  • graphql-query encodes the graph provided under a root (query ...) node.
  • graphql-mutation encodes the graph provided under a root (mutation ...) node. Both macros allow special syntax for query/mutation parameters if this is desired; see the docstrings for details. I will note that backtick notation usually feels more natural in Lisp code.

Basic Queries

The body of these macros is the graph of your query/mutation expressed in a Lispy DSL. Generally speaking, we represent fields as symbols and edges as nested lists with the edge name being the head of that list. For example,

(graphql-query
 (myField1 myField2 (myEdges (edges (node myField3)))))

will construct a query that retrieves myField1, myField2, and myField3 for every node in myEdges. The query is returned as a string without any unnecessary whitespace (i.e., formatting) added.

Following Edges

Multiple edges can of course be followed. Here's an example using GitHub's API:

(graphql-query
 ((viewer login)
  (rateLimit limit cost remaining resetAt)))

Passing Arguments

Usually, queries need explicit arguments. We pass them in an alist set off by the :arguments keyword:

(graphql-query
 ((repository
   :arguments ((owner . "github")
               (name . ($ repo)))
   (issues :arguments ((first . 20)
                       (states . [OPEN CLOSED]))
           (edges
            (node number title url id))))))

As you can see, strings, numbers, vectors, symbols, and variables can all be given as arguments. The above evaluates to the following (formatting added):

query {
  repository (owner: "github", name: $repo) {
    issues (first: 20, states: [OPEN, CLOSED]) {
      edges {
        node {
          number title url id
        }
      }
    }
  }
}

Objects as arguments work, too, though practical examples seem harder to come by:

(graphql-query
 ((object :arguments ((someVariable . ((someComplex . "object")
                                       (with . ($ complexNeeds))))))))

gives

query {
  object (
    someVariable: {
      someComplex: "object",
      with: $complexNeeds
    }
  )
}

Working with Responses

  • graphql-simplify-response-edges Simplify structures like

    (field
     (edges
      ((node node1values...))
      ((node node2values...))))
    

    into (field (node1values) (node2values)).

Keyword Reference

  • :arguments Pass arguments to fields as an alist of parameters (as symbols) to values. See graphql--encode-argument-value.
  • :op-name, :op-params Operation name/parameters. Given to top-level query or mutation operations for later re-use. You should rarely (if ever) need to supply these yourself; the graphql-query and graphql-mutation macros give you natural syntax to do this.

Planned

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].