CrossClj

0.1.0 docs

SourceDocs


project

docs index

NAMESPACES
active-graphql

RECENT

    active-graphql

    Clojars

    Nov 20, 2017


    OWNER
    active-group

    Readme

    Index of all namespaces


    « Project + dependencies

    A ClojureScript library for programmatically building GraphQL query strings

    active-graphql.builder — cljsDocsSource
    Helper functions for easier construction of graphql queries. Most
    importantly, provides the functions field, query and mutation (refer to
    active-graphql.examples for usage).
    active-graphql.core — cljsDocsSource

    VARS

    A ->argument add-selections-to-query-document argument argument-name argument-value argument? arguments-from-map atomic-field

    B ->boolean-argument boolean-arg boolean-argument boolean-argument-arg boolean-argument?

    C create-request

    D ->document document document-definitions document?

    F ->field ->float-argument ->fragment-definition field field* field-alias field-arguments field-directives field-name field-selection-set field? float-arg float-argument float-argument-arg float-argument? fragment-definition fragment-definition? fragment-directives fragment-name fragment-selection-set fragment-type-condition

    G graphql

    I ->int-argument int-arg int-argument int-argument-arg int-argument?

    M make-argument make-boolean-argument make-document make-field make-float-argument make-fragment-definition make-int-argument make-new-operation-definition make-operation-type-query make-result make-string-argument make-uuid-argument map->argument map->boolean-argument map->document map->field map->float-argument map->fragment-definition map->int-argument map->operation-definition map->operation-type-query map->result map->string-argument map->uuid-argument mutation

    O ->operation-definition ->operation-type-query operation-definition operation-definition-definition operation-definition? operation-type-operation-type operation-type-query operation-type-query-directives operation-type-query-name operation-type-query-selection-set operation-type-query-variable-definitions operation-type-query? operation-type-selection-set-lens

    P print-arg-value print-argument print-document print-document-definition print-field print-operation-definition print-operation-type-query print-selection print-selection-set

    Q query

    R ->result result result-data result-data-lens result-errors result?

    S ->string-argument string-arg string-argument string-argument-arg string-argument? stringify subscription

    U ->uuid-argument uuid-arg uuid-argument uuid-argument-arg uuid-argument?

    V valid-result?

    The README below is fetched from the published project artifact. Some relative links may be broken.

    active-graphql

    A ClojureScript library for programmatically building GraphQL query strings. Inlcudes a “micro” DSL for constructing more readable queries.

    Usage

    Some examples for constructing queries using active-graphql:

    (ns active-graphql.examples
      (:require [active-graphql.builder :as b])
    
    (b/query (b/field "user" "firstName" "lastName"))
    ;; =>
    ;; query {
    ;;   user {
    ;;     firstName
    ;;     lastName
    ;;   }
    ;; }
    
    ;; Keywords can be used instead of strings
    (b/query (b/field :user :firstName :lastName))
    ;; =>
    ;; query {
    ;;   user {
    ;;     firstName
    ;;     lastName
    ;;   }
    ;; }
    
    ;; Aliasing
    (b/query (b/field :user
                      [:name :firstName]))
    ;; =>
    ;; query {
    ;;   user {
    ;;     name: firstName
    ;;   }
    ;; }
    
    (b/mutation (b/field "user" "firstName" "lastName"))
    ;; =>
    ;; mutation {
    ;;   user {
    ;;     firstName
    ;;     lastName
    ;;   }
    ;; }
    
    ;; Utilizing arguments to a query:
    (b/query (b/field "user" {"id" 42} "firstName"))
    ;; =>
    ;; query {
    ;;   user(id: 42) {
    ;;     firstName
    ;;   }
    ;; }
    
    ;; Nesting
    (b/query (b/field "user" {"id" 42} "firstName")
             (b/field "hardware" "type" "model"))
    ;; =>
    ;; query {
    ;;   user(id: 42) {
    ;;     firstName
    ;;   }
    ;;   hardware {
    ;;     type
    ;;     model
    ;;   }
    ;; }
    
    ;; Deeper nesting
    (b/query (b/field "user" {"id" 42}
                      "firstName"
                      "other")
             (b/field "person"
                      {"firstName" "Marco"}
                      (b/field "address"
                               "street"
                               "zipCode")))
    ;; query {
    ;;   user(id: 42) {
    ;;     firstName
    ;;     other
    ;;   }
    ;;   person(firstName: "Marco") {
    ;;     address {
    ;;       street
    ;;       zipCode
    ;;     }
    ;;   }
    ;; }
    
    

    License

    Copyright © 2017 Active Group GmbH

    Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.