UNPKG

13.5 kBMarkdownView Raw
1<p align="center"><a href="https://www.graph.cool"><img src="https://imgur.com/he8RLRs.png"></a></p>
2
3[Website](https://www.graph.cool/) • [Docs](https://graph.cool/docs/) • [Blog](https://blogs.graph.cool/) • [Forum](https://www.graph.cool/forum) • [Slack](https://slack.graph.cool/) • [Twitter](https://twitter.com/graphcool)
4
5[![CircleCI](https://circleci.com/gh/graphcool/graphcool.svg?style=shield)](https://circleci.com/gh/graphcool/graphcool) [![Slack Status](https://slack.graph.cool/badge.svg)](https://slack.graph.cool) [![npm version](https://img.shields.io/badge/npm%20package-next-brightgreen.svg)](https://badge.fury.io/js/graphcool)
6
7**The Graphcool backend development framework** is designed to help you develop and deploy production-ready GraphQL microservices. With Graphcool you can design your data model and have a production ready [GraphQL](https://www.howtographql.com/) API online in minutes.
8
9The framework integrates with cloud-native serverless functions and is compatible with existing libraries and tools like [GraphQL.js](https://github.com/graphql/graphql-js) and [Apollo Server](https://github.com/apollographql/apollo-server). Graphcool comes with a CLI and a Docker-based runtime which can be deployed to any server or cloud.
10
11<!--
12Add note that Graphcool can still be used with other langs via webhooks??
13-->
14
15The framework provides powerful abstractions and building blocks to develop flexible, scalable GraphQL backends:
16
171. **GraphQL database** to easily evolve your data schema & migrate your database
182. **Flexible auth** using the JWT-based authentication & permission system
193. **Realtime API** using GraphQL Subscriptions
204. **Highly scalable architecture** enabling asynchronous, event-driven flows using serverless functions
215. **Works with all frontend frameworks** like React, Vue.js, Angular ([Quickstart Examples](https://graph.cool/docs/quickstart/))
22
23## Contents
24
25<img align="right" width="400" src="https://imgur.com/EsopgE3.gif" />
26
27* [Quickstart](#quickstart)
28* [Features](#features)
29* [Examples](#examples)
30* [Architecture](#architecture)
31* [Deployment](#deployment)
32* [FAQ](#faq)
33* [Roadmap](#roadmap)
34* [Community](#community)
35* [Contributing](#contributing)
36
37## Quickstart
38
39> **Note:** This is a preview version of the Graphcool Framework (latest `0.8`). More information in the [forum](https://www.graph.cool/forum/t/feedback-new-cli-beta/949).
40
41[Watch this 5 min tutorial](https://www.youtube.com/watch?v=xmri5pNR9-Y) or follow the steps below to get started with the Graphcool framework:
42
431. **Install the CLI via NPM:**
44
45 ```sh
46 npm install -g graphcool
47 ```
48
492. **Create a new service:**
50
51 The following command creates all files you need for a new [service](https://graph.cool/docs/reference/service-definition/overview-opheidaix3).
52
53 ```sh
54 graphcool init
55 ```
56
573. **Define your data model:**
58
59 Edit `types.graphql` to define your data model using the [GraphQL SDL notation](https://graph.cool/docs/reference/database/data-modelling-eiroozae8u). `@model` types map to the database.
60
61 ```graphql
62 type User @model {
63 id: ID! @isUnique
64 name: String!
65 dateOfBirth: DateTime
66
67 # You can declare relations between models like this
68 posts: [Post!]! @relation(name: "UserPosts")
69 }
70
71
72 type Post @model {
73 id: ID! @isUnique
74 title: String!
75
76 # Relations always have two fields
77 author: User! @relation(name: "UserPosts")
78 }
79
80 ```
81
824. **Define permissions and functions:**
83
84 [`graphcool.yml`](https://graph.cool/docs/reference/service-definition/graphcool.yml-foatho8aip) is the root definition of a service where `types`, `permissions` and `functions` are referenced.
85
86 ```yml
87 # Define your data model here
88 types: types.graphql
89
90 # Configure the permissions for your data model
91 permissions:
92 - operation: "*"
93
94 # tokens granting root level access to your API
95 rootTokens: []
96
97 # You can implement your business logic using functions
98 functions:
99 hello:
100 handler:
101 code: src/hello.js
102 type: resolver
103 schema: src/hello.graphql
104 ```
105
106<!--
1075. **Implement API Gateway layer (optional):**
108-->
109
1105. **Deploy your service:**
111
112 To deploy your service simply run the following command and select either a hosted BaaS [cluster](https://graph.cool/docs/reference/graphcool-cli/.graphcoolrc-zoug8seen4) or setup a local Docker-based development environment:
113
114 ```sh
115 graphcool deploy
116 ```
117
1186. **Connect to your GraphQL endpoint:**
119
120 Use the endpoint from the previous step in your frontend (or backend) applications to connect to your GraphQL API.
121
122## Features
123
124#### Graphcool enables rapid development
125
126* Extensible & incrementally adoptable
127* No vendor lock-in through open standards
128* Rapid development using powerful abstractions and building blocks
129
130#### Includes everything needed for a GraphQL backend
131
132* GraphQL Database with automatic migrations
133* JWT-based authentication & flexible permission system
134* Realtime GraphQL Subscription API
135* GraphQL specfication compliant
136* Compatible with existing libraries and tools (such as GraphQL.js & Apollo)
137
138#### Scalable serverless architecture designed for the cloud
139
140* Docker-based cluster runtime deployable to AWS, Google Cloud, Azure or any other cloud
141* Enables asynchronous, event-driven workflows using serverless functions
142* Http based database connections optimised for serverless functions
143
144#### Integrated developer experience from zero to production
145
146* Rapid local development workflow – also works offline
147* Supports multiple languages including Node.js and Typescript
148* [GraphQL Playground](https://github.com/graphcool/graphql-playground): Interactive GraphQL IDE
149* Supports complex continuous integration/deployment workflows
150
151## Examples
152
153### Service examples
154
155* [auth](auth): Email/password-based authentication
156* [crud-api](crud-api): Simple CRUD-style GraphQL API
157* [env-variables-in-functions](env-variables-in-functions): Function accessing environment variables
158* [full-example](full-example): Full example (webshop) demoing most available features
159* [typescript-gateway-custom-schema](typescript-gateway-custom-schema): Define a custom schema using an API gateway
160* [graphcool-lib](graphcool-lib): Use `graphcool-lib` in functions to send queries and mutations to your service
161* [permissions](permissions): Configure permission rules
162* [rest-wrapper](rest-wrapper): Extend GraphQL API by wrapping existing REST endpoint
163* [subscriptions](subscriptions): Use subscription functions to react to asynchronous events
164* [yaml-variables](yaml-variables): Use variables in your `graphcool.yml`
165
166
167### Frontend examples
168
169* [react-graphql](https://github.com/graphcool-examples/react-graphql): React code examples with GraphQL, Apollo, Relay, Auth0 & more
170* [react-native-graphql](https://github.com/graphcool-examples/react-native-graphql): React Native code examples with GraphQL, Apollo, Relay, Auth0 & more
171* [vue-graphql](https://github.com/graphcool-examples/vue-graphql): Vue.js code examples with GraphQL, Apollo & more
172* [angular-graphql](https://github.com/graphcool-examples/angular-graphql): Angular code examples with GraphQL, Apollo & more
173* [ios-graphql](https://github.com/graphcool-examples/ios-graphql): React code examples with GraphQL, Apollo, Relay, Auth0 & more
174
175## Architecture
176
177Graphcool is a new kind of framework that introduces clear boundaries between your business logic and stateful components. This separation allows the framework to take advantage of modern cloud infrastructure to scale the stateful components without restricting your choice of programming language and development workflow.
178
179![](https://imgur.com/zaaFVnF.png)
180
181## GraphQL Database
182
183The most important component in the Graphcool Framework is the GraphQL Database:
184
185 - Query, mutate & stream data via GraphQL CRUD API
186 - Define and evolve your data model using GraphQL SDL
187
188 If you have used the Graphcool Backend as a Service before, you are already familiar with the benefits of the GraphQL Database.
189
190The CRUD API comes out of the box with advanced features such as pagination, expressive filters and nested mutations. These features are implemented within an effecient data-loader engine, to ensure the best possible performance.
191
192
193## Deployment
194
195Graphcool services can be deployed with [Docker](https://docker.com/) or the [Graphcool Cloud](http://graph.cool/cloud).
196
197### Docker
198
199You can deploy a Graphcool service to a local environment using Docker. To run a graphcool service locally, use the `graphcool local` sub commands.
200
201This is what a typical workflow looks like:
202
203```sh
204graphcool init # bootstrap new Graphcool service
205graphcool local up # start local cluster
206graphcool deploy # deploy to local cluster
207```
208
209### Graphcool Cloud (Backend-as-a-Service)
210
211Services can also be deployed to _shared_ clusters in the Graphcool Cloud. When deploying to a shared cluster, there is a **free developer plan** as well as a convienent and efficient **pay-as-you-go pricing** model for production applications.
212
213The Graphcool Cloud currently supports three [regions](https://blog.graph.cool/new-regions-and-improved-performance-7bbc0a35c880):
214
215- `eu-west-1` (EU, Ireland)
216- `asia-northeast-1` (Asia Pacific, Tokyo)
217- `us-west-1` (US, Oregon)
218
219
220<!--
221
222#### Consumer-driven API contracts
223
224- https://martinfowler.com/articles/consumerDrivenContracts.html
225
226### Open source & Community
227
228The Graphcool Framework is completely open-source and based on open standards. We highly value
229
230- Open Source & Based on open standards
231
232-->
233
234<!--
235
236#### Powerful core
237
238At the core of every Graphcool service is the auto-generated CRUD API that offers a convenient GraphQL-based abstraction over your database.
239
240#### Flexible shell
241
242Business logic, authentication and permissions are implemented with serverless functions that seamlessly integrate with the CRUD API. All communication between different parts of the framework is typesafe thanks to the GraphQL schema.
243
244The API gateway is another tool that provides the power and flexibility needed to build modern applications.
245
246-->
247
248## FAQ
249
250### Wait a minute – isn't Graphcool a Backend-as-a-Service?
251
252While Graphcool started out as a Backend-as-a-Service (like Firebase or Parse), [we're currently in the process](https://blog.graph.cool/graphcool-framework-preview-ff42081b1333) of turning Graphcool into a backend development framework. You can still deploy your Graphcool services to the [Graphcool Cloud](https://graph.cool/cloud), and additionally you can run Graphcool locally or deploy to your own infrastructure.
253
254### Why is Graphcool Core written in Scala?
255
256At the core of the Graphcool Framework is the GraphQL Database, an extremely complex piece of software. We developed the initial prototype with Node but soon realized that it wasn't the right choice for the complexity Graphcool needed to deal with.
257
258We found that to be able to develop safely while iterating quickly, we needed a powerful typesystem. Scala's support for functional programming techniques coupled with the strong performance of the JVM made it the obvious choice for Graphcool.
259
260Another important consideration is that the most mature GraphQL implementation - [Sangria](https://github.com/sangria-graphql) - is written in Scala.
261
262
263### Is the API Gateway layer needed?
264
265The API gateway is an _optional_ layer for your API, adding it to your service is not required. It is however an extremely powerful tool suited for many real-world use cases, for example:
266
267- Tailor your GraphQL schema and expose custom operations (based on the underlying CRUD API)
268- Intercept HTTP requests before they reach the CRUD API; adjust the HTTP response before it's returned
269- Implement persisted queries
270- Integrate existing systems into your service's GraphQL API
271- File management
272
273Also realize that when you're not using an API gateway, _your service endpoint allows everyone to view all the operations of your CRUD API_. The entire data model can be deduced from the exposed CRUD operations.
274
275## Roadmap
276
277
278Help us shape the future of the Graphcool Framework by :thumbsup: [existing Feature Requests](https://github.com/graphcool/framework/issues?q=is%3Aopen+is%3Aissue+label%3Akind%2Ffeature) or [creating new ones](https://github.com/graphcool/framework/issues/new)
279
280We are in the process of setting up a formal roadmap. Check back here in the coming weeks
281to see the new features we are planning!
282
283## Community
284
285Graphcool has a community of thousands of amazing developers and contributors. Welcome, please join us! 👋
286
287- [Forum](https://www.graph.cool/forum)
288- [Slack](https://slack.graph.cool/)
289- [Stackoverflow](https://stackoverflow.com/questions/tagged/graphcool)
290- [Twitter](https://twitter.com/graphcool)
291- [Facebook](https://www.facebook.com/GraphcoolHQ)
292- [Meetup](https://www.meetup.com/graphql-berlin)
293- [Email](hello@graph.cool)
294
295
296## Contributing
297
298Your feedback is **very helpful**, please share your opinion and thoughts!
299
300### +1 an issue
301
302If an existing feature request or bug report is very important for you, please go ahead and :+1: it or leave a comment. We're always open to reprioritize our roadmap to make sure you're having the best possible DX.
303
304### Requesting a new feature
305
306We love your ideas for new features. If you're missing a certain feature, please feel free to [request a new feature here](https://github.com/graphcool/framework/issues/new). (Please make sure to check first if somebody else already requested it.)