Skip to content

Instantly share code, notes, and snippets.

;; Query: A vector of keywords (e.g. [:foo :bar])
(defmacro with-query-bindings
"Binds names derived from a query to the results for the query.
E.g. the query [:foo :bar] is turned into
(let [{foo :foo bar :bar} <query result>]
<body>)"
[query query-result & body]
(let [bindings (query-bindings query)]
~/W/w/macros (master↑1|✔) $ boot pom
java.lang.Thread.run Thread.java: 745
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 617
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1142
java.util.concurrent.FutureTask.run FutureTask.java: 266
...
clojure.core/binding-conveyor-fn/fn core.clj: 2027
boot.core/boot/fn core.clj: 1030
...
boot.core/construct-tasks core.clj: 992
/* GraphQlTag.re */
type query;
type gql = (string => query) [@bs];
external gql : string => query = "default" [@@bs.module "graphql-tag"];
let gql = gql;
@Jannis
Jannis / graphqlws-1.go
Last active December 12, 2017 09:54
Create a GraphQL over WebSocket endpoint with graphqlws
package main
import (
"net/http"
"github.com/functionalfoundry/graphqlws"
"github.com/graphql-go/graphql"
)
func main() {
@Jannis
Jannis / graphqlws-2.go
Last active January 5, 2018 13:41
Working with GraphQL WebSocket subscriptions in graphqlws
// This assumes you have access to the above subscription manager
subscription := subscriptionManager.Subscriptions()
for _, conn := range subscriptions {
// Things you have access to here:
conn.ID() // The connection ID
conn.User() // The user returned from the subscription manager's Authenticate
for _, subscription := range subscriptions[conn] {
// Things you have access to here:
@Jannis
Jannis / graphqlws-3.go
Last active December 12, 2017 09:53
Combining GraphQL over Websocket with graphql-go/handler
package main
import (
"net/http"
"github.com/functionalfoundry/graphqlws"
"github.com/graphql-go/graphql"
"github.com/graphql-go/handler"
)
package main
import (
"fmt"
"net/http"
"github.com/functionalfoundry/graphqlws"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/language/ast"
"github.com/graphql-go/handler"
➜ graphql-js git:(jannis/fix-cyclic-imports) ✗ yarn test
yarn run v1.3.2
$ npm run lint && npm run check && npm run testonly
> @jannispohlmann/[email protected] lint /Users/jannis/Work/oss/graphql/graphql-js
> eslint --rulesdir ./resources/lint src || (printf '\033[33mTry: \033[7m npm run lint -- --fix \033[0m\n' && exit 1)
> @jannispohlmann/[email protected] check /Users/jannis/Work/oss/graphql/graphql-js
> flow check
@Jannis
Jannis / build.clj
Last active May 6, 2020 10:47
Using GraphQL / Apollo Client / React Apollo in the next ClojureScript release
;; Run using a local build of ClojureScript master, e.g.:
;; clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.155"}}}' -i build.clj
(require '[cljs.build.api :as b])
(b/watch "src"
{:output-dir "out"
:output-to "out/main.js"
:optimizations :none
:verbose true
@Jannis
Jannis / groom-concept.md
Last active March 25, 2018 21:44
[WIP] Groom: A React/GraphQL framework for ClojureScript

[WIP] Groom: A React/GraphQL framework for ClojureScript

Principles

  • React for components
  • Component definitions with co-located queries and mutations
  • GraphQL for client-side state management
  • GraphQL for server queries and mutations
  • Prefer data over code (i.e. Hiccup-style UI definitions)
  • Two-level API: