All Projects → AEB-labs → Cruddl

AEB-labs / Cruddl

Licence: mit
Create a GraphQL API for your database, using the GraphQL SDL to model your schema.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Cruddl

Graphql Core
A Python 3.6+ port of the GraphQL.js reference implementation of GraphQL.
Stars: ✭ 344 (+251.02%)
Mutual labels:  graphql, graphql-js
Graphql Iso Date
A set of RFC 3339 compliant date/time GraphQL scalar types.
Stars: ✭ 480 (+389.8%)
Mutual labels:  graphql, graphql-js
Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (+323.47%)
Mutual labels:  graphql, graphql-js
The Road To Graphql
📓The Road to GraphQL: Your journey to master pragmatic GraphQL in JavaScript
Stars: ✭ 203 (+107.14%)
Mutual labels:  graphql, graphql-js
Graphql Log
Add logging to your GraphQL resolvers so you know what's going on in your app.
Stars: ✭ 94 (-4.08%)
Mutual labels:  graphql, graphql-js
Graphql To Mongodb
Allows for generic run-time generation of filter types for existing graphql types and parsing client requests to mongodb find queries
Stars: ✭ 261 (+166.33%)
Mutual labels:  graphql, graphql-js
Graphql Query Complexity
GraphQL query complexity analysis and validation for graphql-js
Stars: ✭ 424 (+332.65%)
Mutual labels:  graphql, graphql-js
Hangzhou Graphql Party
杭州 GraphQLParty 往期记录(slide,照片,预告,视频等)
Stars: ✭ 142 (+44.9%)
Mutual labels:  graphql, graphql-js
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+6904.08%)
Mutual labels:  graphql, graphql-js
React App
Create React App with server-side code support
Stars: ✭ 614 (+526.53%)
Mutual labels:  graphql, graphql-js
Join Monster
A GraphQL to SQL query execution layer for query planning and batch data fetching.
Stars: ✭ 2,395 (+2343.88%)
Mutual labels:  graphql, graphql-js
Graphql Scalars
A library of custom GraphQL Scalars for creating precise type-safe GraphQL schemas.
Stars: ✭ 1,023 (+943.88%)
Mutual labels:  graphql, graphql-js
Grial
A Node.js framework for creating GraphQL API servers easily and without a lot of boilerplate.
Stars: ✭ 194 (+97.96%)
Mutual labels:  graphql, graphql-js
Graphql Js
A reference implementation of GraphQL for JavaScript
Stars: ✭ 18,251 (+18523.47%)
Mutual labels:  graphql, graphql-js
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (+84.69%)
Mutual labels:  graphql, graphql-js
Graphql Tools
🔧 Build, mock, and stitch a GraphQL schema using the schema language
Stars: ✭ 4,556 (+4548.98%)
Mutual labels:  graphql, graphql-js
The Road To Graphql Chinese
📓The Road to GraphQL: Your journey to master pragmatic GraphQL in JavaScript
Stars: ✭ 104 (+6.12%)
Mutual labels:  graphql, graphql-js
Postgraphile
GraphQL is a new way of communicating with your server. It eliminates the problems of over- and under-fetching, incorporates strong data types, has built-in introspection, documentation and deprecation capabilities, and is implemented in many programming languages. This all leads to gloriously low-latency user experiences, better developer experiences, and much increased productivity. Because of all this, GraphQL is typically used as a replacement for (or companion to) RESTful API services.
Stars: ✭ 10,967 (+11090.82%)
Mutual labels:  graphql, graphql-js
Graphql Cost Analysis
A Graphql query cost analyzer.
Stars: ✭ 527 (+437.76%)
Mutual labels:  graphql, graphql-js
Aws Mobile Appsync Sdk Js
JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Stars: ✭ 806 (+722.45%)
Mutual labels:  graphql, graphql-js

cruddl

npm version Build Status Package Quality

cruddl - create a cuddly GraphQL API for your database, using the GraphQL SDL to model your schema.

This TypeScript library creates an executable GraphQL schema from a model definition and provides queries and mutations to access a database. Currently, it supports the multi-model database ArangoDB. The concept being inspired by existing projects like prisma and join-monster, cruddl exploits the expressiveness of the Arango Query Language (AQL) to generate one tailored query for each GraphQL request.

Try it online

Features

  • Schema definition using GraphQL types, fields and directives
  • Modelling features like relations, embedded lists and objects
  • Query features include filtering, sorting, cursor-based pagination and arbitrary nesting
  • Schema validation
  • Role-based authorization (field and type-based; static and data-dependent)
  • Pluggable database backends (currently supports ArangoDB and an in-memory implementation)

Usage

npm install --save cruddl

Install ArangoDB and create a new database.

import { ArangoDBAdapter } from 'cruddl';
const db = new ArangoDBAdapter({
    databaseName: 'databaseName',
    url: 'http://root:@localhost:8529',
    user: 'root',
    password: ''
});

If you just want to explore the features, you can also use an in-memory database implementation - but don't use this for anything else.

import { InMemoryAdapter } from 'cruddl';
const db = new InMemoryAdapter();

Define your data model and create a project:

import { Project } from 'cruddl';
const project = new Project({
    sources: [
        {
            name: 'schema.graphqls',
            body: `
            type Movie @rootEntity {
              title: String
              actors: Actor @relation
            }
            
            type Actor @rootEntity {
              name: String
              movies: Movie @relation(inverseOf: "actors")
            }`
        },
        {
            name: 'permission-profiles.json',
            body: JSON.stringify({
                permissionProfiles: {
                    default: {
                        permissions: [
                            {
                                roles: ['users'],
                                access: 'readWrite'
                            }
                        ]
                    }
                }
            })
        }
    ],
    getExecutionOptions: ({ context }) => ({ authRoles: ['users'] }),
    getOperationIdentifier: ({ context }) => context as object // each operation is executed with an unique context object
});

Then, create the GraphQL schema and serve it:

import { ApolloServer } from 'apollo-server';
const schema = project.createSchema(db);
db.updateSchema(project.getModel()); // create missing collections
const server = new ApolloServer({
    schema,
    context: ({ req }) => req // pass request as context so we have a unique context object for each operation
});
server.listen(4000, () => console.log('Server is running on http://localhost:4000/'));

See the modelling guide and the api documentation for details.

Usage in a browser environment

The core of cruddl perfectly works in a browser (e.g., using webpack), and this can be useful to generate a mock GraphQL schema on the fly or to validate a cruddl project. However, the ArangoDB adapter only works with node imports like path. Unless you configure webpack to provide mock modules for them, you will get an error when you import cruddl in a webpack environment. To solve this, you can import the core symbols from cruddl/core and the InMemoryAdapter from cruddl/inmemory.

Running Tests

For consistency, tests shall be run against a single arangodb node:

  1. npm i
  2. npm run start_arangodb
  3. ensure you have access to console at http://localhost:8529
  4. npm run test

When done, stop the instance with npm run stop_arangodb

Documentation

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