
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
graphql-tools-builder
Advanced tools
 [](https://codecov.io/gh/mrphu3074/graphql-tools-builder)
Create Graphql schema effortlessly
This library like a plugin for graphql-tools
to organize your modules easier.
const typeDefs = `
scalar Date
type User {
_id: String
username: String
password: String
createdAt: Date
modifiedAt: Date
createdBy: String
modifiedBy: String
creator: User
modifier: User
}
input CreateUserForm {
username: String!
password: String!
}
type Query {
#get all users
getUsers: [User]
}
type Mutation {
#Create new user
createUser(data: CreateUserForm!): User
}
`;
const resolvers = {
User: {
creator(root, args, context) {
if(root.createdBy) {
return context.User.findOne({_id: root.createdBy});
}
return null;
},
modifier(root, args, context) {
if(root.modifiedBy) {
return context.User.findOne({_id: root.modifiedBy});
}
return null;
}
},
Query: {
getUsers(root, args, context) {
return context.User.find({});
}
},
Mutation: {
createUser(root, args, context) {
return context.User.insert(args.data);
}
}
}
import { makeExecutableSchema } from 'graphql-tools';
// Generarte main schema
const schema = makeExecutableSchema({
typeDefs,
resolvers
});
import { makeExecutableSchema } from 'graphql-tools';
import { Schema, Module } from 'graphql-tools-builder';
const GraphqlDate = require('graphql-date);
const schema = new Schema();
const commons = new Module('Commons');
const user = new Module('User');
schema.addModule(commons);
schema.addModule(user);
// set up commons type
commons.createScalar('Date').resolver(GraphqlDate);
// set up user module
user.createType('User')
.field('_id', 'String')
.field('username', 'String')
.field('password', 'String')
.field('createdAt', 'Date')
.field('modifiedAt', 'Date')
.field('createdBy', 'String')
.field('modifiedBy', 'String')
.field('creator', 'User')
.field('modifier', 'User')
.resolver({
creator(root, args, context) {
if(root.createdBy) {
return context.User.findOne({_id: root.createdBy});
}
return null;
},
modifier(root, args, context) {
if(root.modifiedBy) {
return context.User.findOne({_id: root.modifiedBy});
}
return null;
}
});
user.createInput('CreateUserForm')
.field('username', 'String', true)
.field('password', 'String', true);
user.createQuery('getUsers')
.output('[User]')
.resolver((root, args, context) => {
return context.User.find({});
});
user.createMutation('createUser')
.param('data', 'CreateUserForm', true)
.output('User')
.resolver((root, args, context) => ({
return context.User.insert(args.data);
}));
// Generarte main schema
const graphqlSchema = makeExecutableSchema({
typeDefs: schema.getTypeDefs(),
resolvers: schema.getResolvers()
});
FAQs
 [](https://codecov.io/gh/mrphu3074/graphql-tools-builder)
The npm package graphql-tools-builder receives a total of 0 weekly downloads. As such, graphql-tools-builder popularity was classified as not popular.
We found that graphql-tools-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.