All Projects → walmartlabs → Lacinia Pedestal

walmartlabs / Lacinia Pedestal

Licence: other
Expose Lacinia GraphQL as Pedestal endpoints

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Lacinia Pedestal

Fakerql
Hosted faker GraphQL endpoint for frontend developers
Stars: ✭ 152 (-3.18%)
Mutual labels:  graphql
Vulcan Next
The Next starter for GraphQL developers
Stars: ✭ 155 (-1.27%)
Mutual labels:  graphql
Countries
🌎 Public GraphQL API for information about countries
Stars: ✭ 156 (-0.64%)
Mutual labels:  graphql
Gatsby Wpgraphql Blog Example
Demo showing how to use WPGraphQL as the source for Gatsby Sites
Stars: ✭ 152 (-3.18%)
Mutual labels:  graphql
Graphql Kafka Subscriptions
Apollo graphql subscriptions over Kafka protocol
Stars: ✭ 154 (-1.91%)
Mutual labels:  graphql
Apollo Opentracing
Performance trace your Apollo GraphQL server with Opentracing
Stars: ✭ 154 (-1.91%)
Mutual labels:  graphql
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+1067.52%)
Mutual labels:  graphql
Combine Pagination
A JavaScript library for paginating data from multiple sources 🦑
Stars: ✭ 157 (+0%)
Mutual labels:  graphql
Payload
Headless CMS and Application Framework built with Node.js, React and MongoDB
Stars: ✭ 154 (-1.91%)
Mutual labels:  graphql
Knests
Full-stack boilerplate (project/hackathon starter) with Docker/NodeJS/Typescript/GraphQL/React/Material-UI
Stars: ✭ 156 (-0.64%)
Mutual labels:  graphql
Next Graphql Blog
🖊 A Blog including a server and a client. Server is built with Node, Express & a customized GraphQL-yoga server. Client is built with React, Next js & Apollo client.
Stars: ✭ 152 (-3.18%)
Mutual labels:  graphql
Gatsby Plugin Algolia
A plugin to push to Algolia based on graphQl queries
Stars: ✭ 154 (-1.91%)
Mutual labels:  graphql
Graphql Java Spring Boot Example
Sample GraphQL server implemented with graphql-java and Spring Boot
Stars: ✭ 155 (-1.27%)
Mutual labels:  graphql
Appsync Refarch Realtime
AWS AppSync Real-Time Reference Architecture
Stars: ✭ 153 (-2.55%)
Mutual labels:  graphql
Reactconfbr
Public infos and issues about React Conf Brasil organization
Stars: ✭ 156 (-0.64%)
Mutual labels:  graphql
Sangria
Scala GraphQL implementation
Stars: ✭ 1,869 (+1090.45%)
Mutual labels:  graphql
Gql Query Builder
🔧 Simple GraphQL Query Builder
Stars: ✭ 155 (-1.27%)
Mutual labels:  graphql
Babel Plugin Graphql Tag
Compiles GraphQL tagged template strings using graphql-tag.
Stars: ✭ 156 (-0.64%)
Mutual labels:  graphql
Graphql Jpa
JPA Implementation of GraphQL (builds on graphql-java)
Stars: ✭ 156 (-0.64%)
Mutual labels:  graphql
Twitter Clone With Graphql Reactnative
Stars: ✭ 155 (-1.27%)
Mutual labels:  graphql

com.walmartlabs/lacinia-pedestal

Clojars Project

CircleCI

A library that adds the Pedestal underpinnings needed when exposing Lacinia as an HTTP endpoint.

Lacinia-Pedestal also supports GraphQL subscriptions, using the same protocol as Apollo GraphQL.

Lacinia-Pedestal Manual | API Documentation

Usage

For a basic Pedestal server, simply supply a compiled Lacinia schema to the com.walmartlabs.lacinia.pedestal2/default-service function to generate a service, then invoke io.pedestal.http/create-server and /start.

;; This example is based off of the code generated from the template
;;  `lein new pedestal-service graphql-demo`

(ns graphql-demo.server
  (:require [io.pedestal.http :as http]
            [com.walmartlabs.lacinia.pedestal2 :as lp]
            [com.walmartlabs.lacinia.schema :as schema]))

(def hello-schema 
(schema/compile
  {:queries 
    {:hello
      ;; String is quoted here; in EDN the quotation is not required
      {:type 'String
       :resolve (constantly "world")}}}))

;; Use default options:
(def service (lp/default-service hello-schema nil))

;; This is an adapted service map, that can be started and stopped
;; From the REPL you can call server/start and server/stop on this service
(defonce runnable-service (http/create-server service))

(defn -main
  "The entry-point for 'lein run'"
  [& args]
  (println "\nCreating your server...")
  (http/start runnable-service))

Lacinia will handle POST requests at the /api endpoint:

$ curl localhost:8888/api -X POST -H "content-type: application/json" -d '{"query": "{ hello }"}'
{"data":{"hello":"world"}}

You can also access the GraphQL IDE at http://localhost:8888/ide.

Development Mode

When developing an application, it is desirable to be able to change the schema without restarting. Lacinia-Pedestal supports this: in the above example, the schema passed to default-service could be a function that returns the compiled schema. It could even be a Var containing the function that returns the compiled schema.

In this way, the Pedestal stack continues to run, but each request rebuilds the compiled schema based on the latest code you've loaded into the REPL.

Beyond default-server

default-server is intentionally limited, and exists only to help you get started. Once you start adding anything more complicated, such as authentication, or supporting multiple schemas (or schema versions) at different paths, you will want to simply create your routes and servers in your own code, using the building-blocks provided by com.walmartlabs.lacinia.pedestal2.

GraphiQL

The GraphiQL packaged inside the library is built using npm, from version 0.12.0.

License

Copyright © 2017-2020 Walmart

Distributed under the Apache Software License 2.0.

GraphiQL has its own license.

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].