Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* @flow */
import { schemaComposer } from 'graphql-compose';
import { FilmTC } from './Film';
import { PeopleTC } from './People';
schemaComposer.Query.addFields({
film: FilmTC.getResolver('findById'),
people: PeopleTC.getResolver('findById'),
peopleByUrl: PeopleTC.getResolver('findByUrl'),
peopleByUrls: PeopleTC.getResolver('findByUrlList'),
});
const schema = schemaComposer.buildSchema();
export default schema;
args: {
limit: { type: 'Int', defaultValue: 3 },
},
type: [ArticleType],
resolve: (_, args) => {
const { limit } = args;
return articles.slice(0, limit);
},
},
authors: {
type: [AuthorType],
resolve: () => authors,
},
});
const schema = schemaComposer.buildSchema();
const server = new ApolloServer({ schema });
server.listen(5000).then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
[modelName+"Connection"] : ModelTC.getResolver('connection'),
[modelName+"Pagination"] : ModelTC.getResolver('pagination'),
});
schemaComposer.Mutation.addFields({
[modelName+"CreateOne"] : ModelTC.getResolver('createOne'),
[modelName+"CreateMany"] : ModelTC.getResolver('createMany'),
[modelName+"UpdateById"] : ModelTC.getResolver('updateById'),
[modelName+"UpdateOne"] : ModelTC.getResolver('updateOne'),
[modelName+"UpdateMany"] : ModelTC.getResolver('updateMany'),
[modelName+"RemoveById"] : ModelTC.getResolver('removeById'),
[modelName+"RemoveOne"] : ModelTC.getResolver('removeOne'),
[modelName+"RemoveMany"] : ModelTC.getResolver('removeMany'),
});
const graphqlSchemaObj = schemaComposer.buildSchema();
const graphqlSDL = printSchema(graphqlSchemaObj, { commentDescriptions: true });
const filename = modelName + '.graphql';
fs.writeFile(`./graphqlsrc/models/${filename}`, graphqlSDL, err => {
if (err) {
return console.log(err);
}
console.log(chalk.white.bgGreen.bold(`Done! Your graphqlSchema has been created and put into your working directory!`, String.fromCharCode(10003)))
console.log(String.fromCharCode(10003));
});
};
verifyRequest: UserTC.getResolver('verifyRequest', [isAuth, isUnverfied]),
verify: UserTC.getResolver('verify'),
resetPassword: UserTC.getResolver('resetPassword', [isGuest, resetPasswordValidator]),
newPassword: UserTC.getResolver('newPassword', [
isGuest,
newPasswordValidator
]),
changePassword: UserTC.getResolver('changePassword', [
isAuth,
changePasswordValidator
]),
updateUser: UserTC.getResolver('updateUser', [isAuth, updateUserValidator]),
switchLocale: UserTC.getResolver('switchLocale', [isAuth])
})
const schema = schemaComposer.buildSchema()
module.exports = schema
[modelName+"Count"] : ModelTC.getResolver('count'),
[modelName+"Connection"] : ModelTC.getResolver('connection'),
[modelName+"Pagination"] : ModelTC.getResolver('pagination'),
});
schemaComposer.Mutation.addFields({
[modelName+"CreateOne"] : ModelTC.getResolver('createOne'),
[modelName+"CreateMany"] : ModelTC.getResolver('createMany'),
[modelName+"UpdateById"] : ModelTC.getResolver('updateById'),
[modelName+"UpdateOne"] : ModelTC.getResolver('updateOne'),
[modelName+"UpdateMany"] : ModelTC.getResolver('updateMany'),
[modelName+"RemoveById"] : ModelTC.getResolver('removeById'),
[modelName+"RemoveOne"] : ModelTC.getResolver('removeOne'),
[modelName+"RemoveMany"] : ModelTC.getResolver('removeMany'),
});
const graphqlSchema = schemaComposer.buildSchema();
return graphqlSchema
}
resolvers => {
schemaComposer.Query.addFields({})
schemaComposer.Mutation.addFields({})
resolvers
.forEach(resolver => {
const kind = resolver._kind
? `${resolver._kind.charAt(0).toUpperCase()}${resolver._kind.slice(1)}`
: 'Query'
schemaComposer[kind].addFields({
[resolver._name]: resolver._gqlResolver
})
})
return schemaComposer.buildSchema()
}