https://github.com/b1f6c1c4/graphql-advanced-projection
Fully customizable Mongoose/MongoDB projection generator.
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
Keywords from Contributors
Repository
Fully customizable Mongoose/MongoDB projection generator.
Basic Info
- Host: GitHub
- Owner: b1f6c1c4
- License: mit
- Language: JavaScript
- Default Branch: master
- Homepage: https://www.npmjs.com/package/graphql-advanced-projection
- Size: 1.32 MB
Statistics
- Stars: 46
- Watchers: 4
- Forks: 5
- Open Issues: 8
- Releases: 0
Topics
Metadata Files
README.md
graphql-advanced-projection
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
examplesfolder.
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
- Repositories: 26
- Profile: https://github.com/b1f6c1c4
52BE D143 A92D BE96 2B83 092B 9BAC 0164 9600 1E70
GitHub Events
Total
Last Year
Committers
Last synced: 12 months ago
Top Committers
| Name | 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
Pull Request Labels
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.
- Homepage: https://github.com/b1f6c1c4/graphql-advanced-projection#readme
- License: MIT
-
Latest release: 2.0.0
published over 3 years ago
Rankings
Maintainers (1)
Dependencies
- 484 dependencies
- @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