aerogear / aerogear/create-graphql

Support raw GraphQL Mutation

Ouverte
#21 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
help wanted new feature
Langage dominant
JavaScript
Étoiles
438
Forks
35
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Example of raw graphql mutation based on https://learngraphql.com/basics/defining-mutations/2

```jsx
const Mutation = new GraphQLObjectType({
name: "BlogMutations",
description: "Mutations of our blog",
fields: () => ({
createPost: {
type: Post,
args: {
title: {type: new GraphQLNonNull(GraphQLString)},
content: {type: new GraphQLNonNull(GraphQLString)}
},
resolve: function(source, args) {
let post = Object.assign({}, args);
// Generate the _id
post._id = `${Date.now()}::${Math.ceil(Math.random() * 9999999)}`;
// Assign a user
post.author = "arunoda";

// Add the Post to the data store
PostsList.push(post);

// return the new post.
return post;
}
}
})
});
```

I think this could work on apollo as well

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.