All Projects β†’ b1f6c1c4 β†’ Graphql Advanced Projection

b1f6c1c4 / Graphql Advanced Projection

Licence: mit
Fully customizable Mongoose/MongoDB projection generator.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Graphql Advanced Projection

Intro To Graphql
[Course] Introduction to GraphQL
Stars: ✭ 175 (+280.43%)
Mutual labels:  graphql, apollo-server, mongoose, mongodb
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 (+230.43%)
Mutual labels:  graphql, apollo, mongoose, mongodb
Boilerplate Vue Apollo Graphql Mongodb
Start your magical stack journey!
Stars: ✭ 85 (+84.78%)
Mutual labels:  graphql, apollo, mongoose, mongodb
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: ✭ 145 (+215.22%)
Mutual labels:  graphql, apollo-server, mongoose, mongodb
Apollo2 Subscriptions How To
Apollo Server 2 how to setup subscriptions
Stars: ✭ 125 (+171.74%)
Mutual labels:  graphql, apollo-server, mongoose, mongodb
Frisky
🍿 Open Source GraphQL API for Online Shows
Stars: ✭ 161 (+250%)
Mutual labels:  graphql, mongoose, mongodb
Sqldatasource
SQL DataSource for Apollo GraphQL projects
Stars: ✭ 176 (+282.61%)
Mutual labels:  graphql, apollo, apollo-server
Feathers Apollo
Feathers and Apollo Server Sample Project
Stars: ✭ 176 (+282.61%)
Mutual labels:  graphql, apollo-server, mongodb
Graphql Apq
🎯 Automatic persisted queries (APQ) for any GraphQL server.
Stars: ✭ 43 (-6.52%)
Mutual labels:  graphql, apollo, apollo-server
Awesome Apollo Graphql
A curated list of amazingly awesome things regarding Apollo GraphQL ecosystem 🌟
Stars: ✭ 126 (+173.91%)
Mutual labels:  graphql, apollo, apollo-server
Blog Service
blog service @nestjs
Stars: ✭ 188 (+308.7%)
Mutual labels:  graphql, mongoose, mongodb
Graphql Modules
Enterprise Grade Tooling For Your GraphQL Server
Stars: ✭ 962 (+1991.3%)
Mutual labels:  graphql, apollo, apollo-server
Portara
Portara directive is a rate limiter / throttler for GraphQL
Stars: ✭ 158 (+243.48%)
Mutual labels:  graphql, apollo, apollo-server
Firestore Apollo Graphql
An example of a GraphQL setup with a Firebase Firestore backend. Uses Apollo Engine/Server 2.0 and deployed to Google App Engine.
Stars: ✭ 371 (+706.52%)
Mutual labels:  graphql, apollo, apollo-server
Nestjs Query
Easy CRUD for GraphQL.
Stars: ✭ 325 (+606.52%)
Mutual labels:  graphql, mongoose, mongodb
Example Storefront
Example Storefront is Reaction Commerce’s headless ecommerce storefront - Next.js, GraphQL, React. Built using Apollo Client and the commerce-focused React UI components provided in the Storefront Component Library (reactioncommerce/reaction-component-library). It connects with Reaction backend with the GraphQL API.
Stars: ✭ 471 (+923.91%)
Mutual labels:  graphql, apollo, mongodb
Express Graphql Mongodb Boilerplate
A boilerplate for Node.js apps / GraphQL-API / Authentication from scratch - express, graphql - (graphql compose), mongodb (mongoose).
Stars: ✭ 288 (+526.09%)
Mutual labels:  graphql, mongoose, mongodb
Graphql Nodejs Hapi Api
How to set-up a powerful API with Nodejs, GraphQL, MongoDB, Hapi, and Swagger
Stars: ✭ 116 (+152.17%)
Mutual labels:  graphql, mongoose, mongodb
Pup
The Ultimate Boilerplate for Products.
Stars: ✭ 563 (+1123.91%)
Mutual labels:  graphql, apollo, mongodb
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: ✭ 307 (+567.39%)
Mutual labels:  graphql, mongoose, mongodb

graphql-advanced-projection

npm npm GitHub last commit GitHub code size in bytes license

Travis Coveralls Greenkeeper badge Badges

Fully customizable Mongoose/MongoDB projection generator.

Why

We already have graphql-projection, graphql-mongodb-projection, and graphql-db-projection. But graphql-advanced-projection is different from all of them above in the following ways:

  • Separete graphql schema and mongodb projection config. This helps you decouple schema and mongodb into two parts, each of them may change independently. Write graphql in .graphql, write config in javascript or .json.
  • Easy customization. No more gqlField: { type: new GraphQLNonNull(GraphQLInt), projection: 'mongoField' }. Simply gqlField: 'mongoField'.
  • We create resolvers. gqlField: (parent) => parent.mongoField can be automatically generated, even complicated ones like first: (parent) => parent.items.data[0].value.
  • Fully supports interfaces, fragments, and inline fragments. Write typeProj: 'type' and switch (parent.type) in __resolveType.

Installation

$ yarn add graphql-advanced-projection

Usage

For a complete working demo, see the examples folder.

Setup mongoose

const UserSchema = new mongoose.Schema({
  _id: String,
  mongoA: String,
});
const User = mongoose.model('users', UserSchema);

Setup graphql

type Query {
  user(id: ID!): User
}
type User {
  userId: ID
  field1: String
  field2: String
}

Setup graphql-advanced-projection

const { project, resolvers } = gqlProjection({
  User: {
    proj: {
      userId: '_id',
      field1: 'mongoA',
      field2: null,
    },
  },
});

Combine everything together

module.exports = makeExecutableSchema({
  typeDefs,
  resolvers: _.merge(resolvers, {
    Query: {
      async user(parent, args, context, info) {
        const proj = project(info);
        const result = await User.findById(args.id, proj);
        return result.toObject();
      },
    },
    User: {
      field2: () => 'Hello World',
    },
  }),
  resolverValidationOptions: { requireResolversForResolveType: false },
});

Run

query {
  user(id: $id) {
    field1
    field2
  }
}
proj = {
  _id: 0,
  mongoA: 1,
}

License

MIT

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