https://github.com/b1f6c1c4/graphql-advanced-projection

Fully customizable Mongoose/MongoDB projection generator.

https://github.com/b1f6c1c4/graphql-advanced-projection

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.7%) to scientific vocabulary

Keywords

apollo apollo-server graphql graphql-advanced-projection graphql-projection javascript mongodb mongoose projection

Keywords from Contributors

interactive charting generic sequences archival controllers embedded projections genomics observability
Last synced: 5 months ago · JSON representation

Repository

Fully customizable Mongoose/MongoDB projection generator.

Basic Info
Statistics
  • Stars: 46
  • Watchers: 4
  • Forks: 5
  • Open Issues: 8
  • Releases: 0
Topics
apollo apollo-server graphql graphql-advanced-projection graphql-projection javascript mongodb mongoose projection
Created almost 8 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

graphql-advanced-projection

npm npm GitHub last commit GitHub code size in bytes license

Appveyor Build Coveralls

Fully customizable Mongoose/MongoDB projection generator.

Why

We already have graphql-projection, graphql-mongodb-projection, graphql-db-projection, and graphql-fields-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

sh $ npm i graphql-advanced-projection

Usage

For a complete working demo, see the examples folder.

Setup mongoose

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

Setup graphql

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

Setup graphql-advanced-projection

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

Combine everything together

```js const { makeExecutableSchema } = require('@graphql-tools/schema');

/* ... */

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

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

License

MIT

Owner

  • Login: b1f6c1c4
  • Kind: user
  • Location: NJ, USA
  • Company: Princeton University

52BE D143 A92D BE96 2B83 092B 9BAC 0164 9600 1E70

GitHub Events

Total
Last Year

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 215
  • Total Committers: 4
  • Avg Commits per committer: 53.75
  • Development Distribution Score (DDS): 0.502
Past Year
  • Commits: 7
  • Committers: 1
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
dependabot[bot] 4****] 107
b1f6c1c4 b****4@g****m 105
Mathieu TUDISCO d****v@m****h 2
greenkeeper[bot] g****] 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 5
  • Total pull requests: 157
  • Average time to close issues: 11 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 4
  • Total pull request authors: 4
  • Average comments per issue: 2.8
  • Average comments per pull request: 0.88
  • Merged pull requests: 109
  • Bot issues: 1
  • Bot pull requests: 153
Past Year
  • Issues: 0
  • Pull requests: 5
  • Average time to close issues: N/A
  • Average time to close pull requests: 14 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.8
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 5
Top Authors
Issue Authors
  • mathieutu (2)
  • greenkeeper[bot] (1)
  • blissi (1)
  • mtscflorin (1)
  • dependabot[bot] (1)
Pull Request Authors
  • dependabot[bot] (168)
  • greenkeeper[bot] (5)
  • mathieutu (3)
  • b1f6c1c4 (1)
Top Labels
Issue Labels
enhancement (2) question (1) greenkeeper (1) wontfix (1) dependencies (1)
Pull Request Labels
dependencies (168) greenkeeper (5) enhancement (3) help wanted (1) bug (1)

Packages

  • Total packages: 1
  • Total downloads:
    • npm 250 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 5
  • Total versions: 14
  • Total maintainers: 1
npmjs.org: graphql-advanced-projection

Fully customizable Mongoose/MongoDB projection generator.

  • Versions: 14
  • Dependent Packages: 1
  • Dependent Repositories: 5
  • Downloads: 250 Last month
Rankings
Downloads: 4.8%
Dependent repos count: 5.0%
Stargazers count: 6.2%
Forks count: 7.7%
Average: 8.9%
Dependent packages count: 21.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

package-lock.json npm
  • 484 dependencies
package.json npm
  • @graphql-tools/schema ^8.3.1 development
  • coveralls ^3.1.1 development
  • eslint ^8.21.0 development
  • eslint-config-airbnb-base ^15.0.0 development
  • eslint-plugin-import ^2.26.0 development
  • eslint-plugin-lodash-fp ^2.2.0-a1 development
  • graphql ^16.5.0 development
  • jest-cli ^28.1.0 development
  • jest-mongoose ^2.0.0 development
  • mongoose ^6.5.0 development
  • debug ^4.3.4
  • lodash ^4.17.21