Skip to content

Commit

Permalink
Merge pull request #4 from CodeWithMeJs/Mutation_Add_Blog
Browse files Browse the repository at this point in the history
[Added] Mutation Add Blog
  • Loading branch information
SwapnadeepTech authored Oct 1, 2021
2 parents ad3a4b0 + d144b06 commit 6e97448
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
console.log("Hello World");
const { ApolloServer } = require("apollo-server");
const resolvers = require("./src/resolvers");
const typeDefs = require("./src/typeDefs");

const server = new ApolloServer({
resolvers,
typeDefs,
});

server.listen().then(({ url, subscriptionsUrl }) => {
console.log(`⚡ Server ready at ${url}`);
console.log(`⚡ Subscriptions ready at ${subscriptionsUrl}`);
});
9 changes: 9 additions & 0 deletions src/resolvers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const resolvers = {
Mutation: {
addBlog: (root, args) => {
console.log("BLOG", args);
},
},
};

module.exports = resolvers;
49 changes: 49 additions & 0 deletions src/typeDefs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { gql } = require("apollo-server");

const typeDefs = gql`
type Blog {
id: ID
title: String
short_desc: String
full_blog: String
author: Author
cover_image: String
tags: [String]
view_count: Int
likes_count: Int
comment_count: Int
comments: [Comment]
slug: String
reading_time: Int
}
type Comment {
id: ID
text: String
}
type Author {
name: String
username: String
profile_image: String
total_followers: Int
total_blog_count: Int
}
type Query {
blogs: [Blog]
}
type Mutation {
addBlog(
title: String
short_desc: String
full_blog: String
author: String
cover_image: String
tags: [String]
): Blog
}
`;

module.exports = typeDefs;

0 comments on commit 6e97448

Please sign in to comment.