All Projects → Webtomizer → Typeorm Loader

Webtomizer / Typeorm Loader

A database-aware data-loader for use with GraphQL and TypeORM.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Typeorm Loader

Graphjin
GraphJin - Build APIs in 5 minutes with GraphQL. An instant GraphQL to SQL compiler.
Stars: ✭ 1,264 (+1369.77%)
Mutual labels:  graphql, database
Eliasdb
EliasDB a graph-based database.
Stars: ✭ 611 (+610.47%)
Mutual labels:  graphql, database
V8 Archive
Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
Stars: ✭ 486 (+465.12%)
Mutual labels:  graphql, database
Awesome Wp Speed Up
Plugins and resources to speed up and optimize your WordPress site.
Stars: ✭ 375 (+336.05%)
Mutual labels:  database, caching
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-37.21%)
Mutual labels:  database, caching
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+393.02%)
Mutual labels:  database, caching
Edgedb
The next generation relational database.
Stars: ✭ 5,368 (+6141.86%)
Mutual labels:  graphql, database
Altair
✨⚡️ A beautiful feature-rich GraphQL Client for all platforms.
Stars: ✭ 3,827 (+4350%)
Mutual labels:  graphql, database
Niklick
Rails Versioned API solution template for hipsters! (Ruby, Ruby on Rails, REST API, GraphQL, Docker, RSpec, Devise, Postgress DB)
Stars: ✭ 39 (-54.65%)
Mutual labels:  graphql, database
Fullstack Graphql
🌈 Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.
Stars: ✭ 955 (+1010.47%)
Mutual labels:  graphql, database
Opencrud
OpenCRUD is a GraphQL CRUD API specification for databases
Stars: ✭ 350 (+306.98%)
Mutual labels:  graphql, database
Neo4j Graphql
An optimized neo4j query resolver for Facebook's GraphQL
Stars: ✭ 60 (-30.23%)
Mutual labels:  graphql, database
Prisma1
💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB)
Stars: ✭ 16,851 (+19494.19%)
Mutual labels:  graphql, database
Graphql Compiler
Turn complex GraphQL queries into optimized database queries.
Stars: ✭ 447 (+419.77%)
Mutual labels:  graphql, database
Graphql Cache
A caching plugin for graphql-ruby
Stars: ✭ 313 (+263.95%)
Mutual labels:  graphql, caching
Weaviate
Weaviate is a cloud-native, modular, real-time vector search engine
Stars: ✭ 509 (+491.86%)
Mutual labels:  graphql, database
Graphik
Graphik is a Backend as a Service implemented as an identity-aware document & graph database with support for gRPC and graphQL
Stars: ✭ 277 (+222.09%)
Mutual labels:  graphql, database
Dgraph
Native GraphQL Database with graph backend
Stars: ✭ 17,127 (+19815.12%)
Mutual labels:  graphql, database
Pizzaql
🍕 Modern OSS Order Management System for Pizza Restaurants
Stars: ✭ 631 (+633.72%)
Mutual labels:  graphql, database
Wertik Js
💪 A library that powers your app with GraphQL + Rest API
Stars: ✭ 56 (-34.88%)
Mutual labels:  graphql, database

Archived

This package is deprecated, please use: https://gitlab.com/Mando75/typeorm-graphql-loader/

typeorm-loader

A database-aware data-loader for use with GraphQL and TypeORM.

Description

This package exports GraphQLDatabaseLoader, which is a caching loader that folds a batch of different database queries into a singular database request.

Installation

npm install typeorm-loader --save

Usage

You should instantiate a new loader per session (just to be on the safe side, you don't want data leaking between user sessions), you instantiate it by passing the TypeORM connection as the first argument.

  import { GraphQLDatabaseLoader } from 'typeorm-loader';

  const connection = createConnection({ ... });
  const loader = new GraphQLDatabaseLoader(connection);

After which you would use it like so:

  Query: {
    getUserById: async (_: any, args: { id: string }, context: any, info: GraphQLResolveInfo) => {
      const result = await loader.loadOne(User, { id }, info);
      return result;
    }
  }

API

/**
 * Load an entity from the database.
 * @param {typeof BaseEntity} entity The entity type to load.
 * @param where Query conditions.
 * @param {GraphQLResolveInfo} info (optional) GraphQL resolver information. If not provided, all fields are returned.
 * @returns {Promise<T>}
 */
async loadOne<T>(entity: Function, where: Partial<T>, info?: GraphQLResolveInfo): Promise<T | undefined>;

/**
 * Load multiple entities that meet the same criteria .
 * @param {Function} entity The entity type to load.
 * @param {Partial<T>} where The conditions to match.
 * @param {GraphQLResolveInfo} info (optional)  GraphQL resolver information. If not provided, all fields are returned.
 * @returns {Promise<T?[]>}
 */
async loadMany<T>(entity: Function, where: Partial<T>, info?: GraphQLResolveInfo): Promise<(T|undefined)[]>;

/**
 * Load multiple entities with different criteria.
 * @param {Function} entity The entity type to load.
 * @param {Partial<T>[]} where A series of conditions to match.
 * @param {GraphQLResolveInfo} info (optional)  GraphQL resolver information. If not provided, all fields are returned.
 * @returns {Promise<T?[]>}
 */
async batchLoadMany<T>(entity: Function, where: Partial<T>[], info?: GraphQLResolveInfo): Promise<(T|undefined)[]>;

/**
 * Clears the loader cache.
 */
clear(): void;

License (MIT)

Copyright 2017 Abdullah Ali

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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