This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filter = new BadWordsFilter(); | |
const hooks = { | |
mutation: { | |
pre: (next, todo, ...rest) => { | |
if (todo.text) { | |
todo.text = filter.clean(todo.text); | |
} | |
next(todo, ...rest); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import graffiti from '../'; | |
import schema from './schema'; | |
const app = express(); | |
app.use(graffiti.express({ | |
schema | |
})); | |
app.listen(3001, (err) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose'; | |
import User from './user'; | |
import Pet from './pet'; | |
import {getSchema} from '@risingstack/graffiti-mongoose'; | |
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/graphql'); | |
export default getSchema([Pet, User]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose'; | |
const PetSchema = new mongoose.Schema({ | |
name: { | |
type: String | |
}, | |
type: { | |
type: String | |
}, | |
age: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation FixName { | |
updateUser(input: {clientMutationId: "2", id: "VXNlcjo1NjQwYTJiNTU1MzBmOGFhNTBlM2NkNGQ=", name: "New User"}) { | |
changedUser { | |
name | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation AddUser { | |
addUser(input: {clientMutationId: "1", name: "New Usr"}) { | |
changedUserEdge { | |
node { | |
id | |
name | |
createdAt | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query UsersPagination { | |
viewer { | |
users(first: 2, after: "Y29ubmVjdGlvbi41NjQwOWMwZjU1MzBmOGFhNTBlM2NjZWE=") { | |
count | |
edges { | |
cursor | |
node { | |
name | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query ConnectionTypeIntrospection { | |
__type(name: "UserConnection") { | |
name | |
fields { | |
name | |
type { | |
kind | |
ofType { | |
name | |
kind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query ReFetch { | |
node(id: "VXNlcjo1NjQwOThlNTI3ZjUyYTg0NTBiNWE5NDQ=") { | |
__typename | |
... on User { | |
name | |
age | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose'; | |
const UserSchema = new mongoose.Schema({ | |
name: { | |
type: String | |
}, | |
age: { | |
type: Number, | |
index: true | |
}, |