Skip to content

Instantly share code, notes, and snippets.

➜ graphql-js git:(jannis/fix-cyclic-imports) ✗ yarn test
yarn run v1.3.2
$ npm run lint && npm run check && npm run testonly
> @jannispohlmann/graphql@0.13.1 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/graphql@0.13.1 check /Users/jannis/Work/oss/graphql/graphql-js
> flow check
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"
@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"
)
@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-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() {
/* GraphQlTag.re */
type query;
type gql = (string => query) [@bs];
external gql : string => query = "default" [@@bs.module "graphql-tag"];
let gql = gql;
~/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
;; 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)]
;;;; Deep destructuring characteristics
;; Regular properties
Query: [a b]
Result: {:a <aval> :b <bval>}
Bindings:
a -> <aval>
b -> <bval>
boot.user=> (clojure.spec/def ::foo (clojure.spec/with-gen ::bar #(clojure.spec.gen/symbol)))
:boot.user/foo
boot.user=> (clojure.spec/describe :boot.user/foo)
:clojure.spec/unknown
boot.user=> (clojure.spec/def ::bar symbol?)
:boot.user/bar
boot.user=> (clojure.spec/describe :boot.user/foo)
:clojure.spec/unknown