$ sudo docker pull blabla1337/owasp-skf-lab:js-graphql-mutations$ sudo docker run -ti -p 127.0.0.1:5000:5000 blabla1337/owasp-skf-lab:js-graphql-mutationsmutation{
createPost(title: "This is a new title", body: "This is a new post", author_id: 2 ){
id
title
body
author_id
}
}const mutationType = new graphql.GraphQLObjectType({
name: "Mutation",
fields: {
createPost: {
type: PostType,
args: {
title: {
type: new graphql.GraphQLNonNull(graphql.GraphQLString),
},
body: {
type: new graphql.GraphQLNonNull(graphql.GraphQLString),
},
author_id: { type: new graphql.GraphQLNonNull(graphql.GraphQLID) },
},
resolve: (root, { title, body, author_id }) => {
return new Promise((resolve, reject) => {
database.run(
"INSERT INTO Posts (title, body, author_id) VALUES (?,?,?);",
[title, body, author_id],
(err) => {
if (err) {
reject(null);
}
database.get("SELECT last_insert_rowid() as id", (err, row) => {
resolve({
id: row["id"],
title: title,
body: body,
author_id: author_id,
});
});
}
);
});
},
},
},
});



$ sudo docker pull blabla1337/owasp-skf-lab:graphql-mutation$ sudo docker run -ti -p 127.0.0.1:5000:5000 blabla1337/owasp-skf-lab:graphql-mutationmutation {
createPost(input: {body: "' -- ", title: "test_title", authorId: 2}) {
post {
body
authorId
title
}
}
}class CreatePost(graphene.Mutation):
"""Mutation to create a post."""
post = graphene.Field(lambda: PostObject, description="Post created by this mutation.")
class Arguments:
input = CreatePostInput(required=True)
def mutate(self, info, input):
post = Post(**input)
db.session.add(post)
db.session.commit()
return CreatePost(post=post)$ sudo docker pull blabla1337/owasp-skf-lab:java-graphql-mutation$ sudo docker run -ti -p 127.0.0.1:5000:5000 blabla1337/owasp-skf-lab:java-graphql-mutationmutation {
createPost(title: "This is a new title", body: "This is a new post", author_id: 2) {
id
title
body
}
}public Post createPost(String title, String body, int user_id) throws org.hibernate.exception.GenericJDBCException{
Post post = new Post();
post.setTitle(title);
post.setBody(body);
post.setUser(new User(user_id));
postRepository.save(post);
return post;
}






