Skip to content

Commit

Permalink
tumblr done
Browse files Browse the repository at this point in the history
  • Loading branch information
longshuicy authored Apr 22, 2017
1 parent ca5c6b7 commit 6c3b546
Show file tree
Hide file tree
Showing 14 changed files with 627 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const spotifyQueryType = require('./spotifySchema');
const youtubeQueryType = require('./youtubeSchema');
const redditQueryType = require('./redditSchema');
const weiboQueryType = require('./weiboSchema');
const tumblrQueryType = require('./tumblrSchema');

function wrapper(){
return {}
Expand Down Expand Up @@ -50,6 +51,10 @@ const Query = new GraphQLObjectType({
type: weiboQueryType,
resolve:() => wrapper()
},
tumblr:{
type:tumblrQueryType,
resolve:() => wrapper()
},
stackExchange: {
type: stackExchangeQueryType,
resolve:() => wrapper()
Expand Down
38 changes: 38 additions & 0 deletions data/schema/tumblr-type/tumblrAnswerPostType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean
} = require('graphql');

const tumblrAnswerPostType = module.exports = new GraphQLObjectType({
name:'tumblrAnswerPostType',
description:'',
fields: () => ({
type: {type:GraphQLString},
blog_name: {type:GraphQLString},
id: {type:GraphQLString},
post_url: {type:GraphQLString},
date: {type:GraphQLString},
timestamp: {type:GraphQLString},
format: {type:GraphQLString},
reblog_key: {type:GraphQLString},
tags: {type:new GraphQLList(GraphQLString)},
bookmarklet: {type:GraphQLBoolean},
mobile: {type:GraphQLBoolean},
source_url: {type:GraphQLString},
source_title: {type:GraphQLString},
liked: {type:GraphQLBoolean},
state: {type:GraphQLString},
total_posts: {type:GraphQLInt},
note_count: {type:GraphQLInt},

asking_name: {type:GraphQLString},
asking_url: {type:GraphQLString},
question: {type:GraphQLString},
answer: {type:GraphQLString},
})
});
43 changes: 43 additions & 0 deletions data/schema/tumblr-type/tumblrAudioPostType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean
} = require('graphql');

const tumblrAudioPostType = module.exports = new GraphQLObjectType({
name:'tumblrAudioPostType',
description:'',
fields: () => ({
type: {type:GraphQLString},
blog_name: {type:GraphQLString},
id: {type:GraphQLString},
post_url: {type:GraphQLString},
date: {type:GraphQLString},
timestamp: {type:GraphQLString},
format: {type:GraphQLString},
reblog_key: {type:GraphQLString},
tags: {type:new GraphQLList(GraphQLString)},
bookmarklet: {type:GraphQLBoolean},
mobile: {type:GraphQLBoolean},
source_url: {type:GraphQLString},
source_title: {type:GraphQLString},
liked: {type:GraphQLBoolean},
state: {type:GraphQLString},
total_posts: {type:GraphQLInt},
note_count: {type:GraphQLInt},

caption: {type:GraphQLString},
player: {type:GraphQLString},
plays: {type:GraphQLInt},
album_art: {type:GraphQLString},
artist: {type:GraphQLString},
album: {type:GraphQLString},
track_name: {type:GraphQLString},
track_number: {type:GraphQLInt},
year: {type:GraphQLInt},
})
});
33 changes: 33 additions & 0 deletions data/schema/tumblr-type/tumblrBlogInfoType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean
} = require('graphql');

const tumblrBlogInfoType = module.exports = new GraphQLObjectType({
name:'tumblrBlogInfo',
description:'',
fields: () => ({
ask: {type:GraphQLBoolean},
ask_anon: {type:GraphQLBoolean},
ask_page_title: {type:GraphQLString},
can_subscribe: {type:GraphQLBoolean},
description: {type:GraphQLString},
is_adult: {type:GraphQLBoolean},
is_nsfw: {type:GraphQLBoolean},
likes: {type:GraphQLInt},
name: {type:GraphQLString},
posts: {type:GraphQLInt},
reply_conditions: {type:GraphQLString},
share_likes: {type:GraphQLBoolean},
subscribed: {type:GraphQLBoolean},
title: {type:GraphQLString},
total_posts: {type:GraphQLInt},
updated: {type:GraphQLInt},
url: {type:GraphQLString},
})
});
148 changes: 148 additions & 0 deletions data/schema/tumblr-type/tumblrBlogType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
var {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean
} = require('graphql');
var tumblrAPI = require('../../../API/tumblrAPI');

const tumblrBlogType = module.exports = new GraphQLObjectType({
name:'tumblrBlog',
description:'',
fields: () => ({
type: {type:GraphQLString},
blog_name: {type:GraphQLString},
id: {type:GraphQLString},
post_url: {type:GraphQLString},
slug: {type:GraphQLString},
date: {type:GraphQLString},
timestamp: {type:GraphQLString},
state: {type:GraphQLString},
format: {type:GraphQLString},
reblog_key: {type:GraphQLString},
tags: {type:new GraphQLList(GraphQLString)},
short_url: {type:GraphQLString},
summary: {type:GraphQLString},
recommended_source: {type:GraphQLString},
recommended_color: {type:GraphQLString},
note_count: {type:GraphQLInt},
caption: {type:GraphQLString},
reblog_tree_html: {type:GraphQLString,
resolve:({reblog}) => {return reblog.tree_html}},
reblog_comment: {type:GraphQLString,
resolve:({reblog}) => {return reblog.comment}},
can_like: {type:GraphQLBoolean},
can_reblog: {type:GraphQLBoolean},
can_send_in_message:{type:GraphQLBoolean},
can_reply: {type:GraphQLBoolean},
display_avatar: {type:GraphQLBoolean},
trail: {type:new GraphQLList(tumblrTrailType)},
photoset_layout: {type:GraphQLString},
photos: {type:new GraphQLList(tumblrPhotoType)},
featured_in_tag: {type:new GraphQLList(GraphQLString)},
featured_timestamp: {type:GraphQLString},

liked_timestamp: {type:GraphQLString},

/*---------------------------------nested-----------------------------------*/
info: {type:tumblrBlogInfoType,
resolve:({blog_name})=>tumblrAPI(resolveName='blogInfo',id=blog_name,args={})},
// careful, some return API error 403
likes: {type:new GraphQLList(tumblrBlogType),
description:'This method can be used to retrieve the publicly exposed likes from a blog.',
args:{
limit: {type:GraphQLInt,
defaultValue:5},
offset: {type:GraphQLInt,
description:'Liked post number to start at',
defaultValue:0 },
before: {type:GraphQLString,
description:'Retrieve posts liked before the specified timestamp'},
after: {type:GraphQLString,
description:'Retrieve posts liked after the specified timestamp'},
},
resolve: ({blog_name},args) =>tumblrAPI(resolveName='blogLikes',id=blog_name,args=args)},
posts: {type:new GraphQLList(tumblrPostType),
description:'Retrieve published posts for a blog',
args:{
type: {type:GraphQLString,
description:'choose between text, quote, link, answer, video, audio, photo, chat'},
id: {type:GraphQLString},
tag: {type:GraphQLString},
limit: {type:GraphQLInt,
defaultValue:5},
offset: {type:GraphQLInt,
description:'Liked post number to start at',
defaultValue:0 },
reblog_info: {type:GraphQLBoolean,
defaultValue:false},
notes_info: {type:GraphQLBoolean,
defaultValue:false},
fliter: {type:GraphQLString,
description:'choose between text, html, text, raw'}
},
resolve:({blog_name},args) =>tumblrAPI(resolveName='blogPosts',id=blog_name,args=args)
},
})
});

const tumblrTrailType = new GraphQLObjectType({
name:'tumblrTrail',
fields: () => ({
blog: {type:tempBlogType},
post_id: {type:GraphQLString,
resolve: ({post})=>{return post.id}},
content_raw: {type:GraphQLString},
content: {type:GraphQLString},
is_current_item: {type:GraphQLBoolean},
is_root_item: {type:GraphQLBoolean},

})
});

const tempBlogType = new GraphQLObjectType({
name:'tempBlog',
fields: () =>({
name: {type:GraphQLString},
active: {type:GraphQLBoolean},
theme: {type:tempThemeType},
share_likes: {type:GraphQLBoolean},
share_following:{type:GraphQLBoolean},
can_be_followed:{type:GraphQLBoolean},
})
});

const tempThemeType = new GraphQLObjectType({
name:'tempTheme',
fields: () =>({
header_full_width: {type:GraphQLInt},
header_full_height: {type:GraphQLInt},
header_focus_width: {type:GraphQLInt},
header_focus_height: {type:GraphQLInt},
avatar_shape: {type:GraphQLString},
background_color: {type:GraphQLString},
body_font: {type:GraphQLString},
header_bounds: {type:GraphQLString},
header_image: {type:GraphQLString},
header_image_focused: {type:GraphQLString},
header_image_scaled: {type:GraphQLString},
header_stretch: {type:GraphQLBoolean},
link_color: {type:GraphQLString},
show_avatar: {type:GraphQLBoolean},
show_description: {type:GraphQLBoolean},
show_header_image: {type:GraphQLBoolean},
show_title: {type:GraphQLBoolean},
title_color: {type:GraphQLString},
title_font: {type:GraphQLString},
title_font_weight: {type:GraphQLString},
})
});

const tumblrBlogInfoType = require('./tumblrBlogInfoType');
const tumblrPhotoType = require('./tumblrPhotoType');
const tumblrPostType = require('./tumblrPostType');


46 changes: 46 additions & 0 deletions data/schema/tumblr-type/tumblrChatPostType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean
} = require('graphql');

const tumblrChatPostType = module.exports = new GraphQLObjectType({
name:'tumblrChatPostType',
description:'',
fields: () => ({
type: {type:GraphQLString},
blog_name: {type:GraphQLString},
id: {type:GraphQLString},
post_url: {type:GraphQLString},
date: {type:GraphQLString},
timestamp: {type:GraphQLString},
format: {type:GraphQLString},
reblog_key: {type:GraphQLString},
tags: {type:new GraphQLList(GraphQLString)},
bookmarklet: {type:GraphQLBoolean},
mobile: {type:GraphQLBoolean},
source_url: {type:GraphQLString},
source_title: {type:GraphQLString},
liked: {type:GraphQLBoolean},
state: {type:GraphQLString},
total_posts: {type:GraphQLInt},
note_count: {type:GraphQLInt},

title: {type:GraphQLString},
body: {type:GraphQLString},
dialogue: {type:new GraphQLList(tumblrDialogueType)},
})
});

const tumblrDialogueType = new GraphQLObjectType({
name:'tumblrDialogue',
fields: () =>({
label: {type:GraphQLString},
name: {type:GraphQLString},
phrase: {type:GraphQLString},
})
});
42 changes: 42 additions & 0 deletions data/schema/tumblr-type/tumblrLinkPostType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean
} = require('graphql');

const tumblrLinkPostType = module.exports = new GraphQLObjectType({
name:'tumblrLinkPostType',
description:'',
fields: () => ({
type: {type:GraphQLString},
blog_name: {type:GraphQLString},
id: {type:GraphQLString},
post_url: {type:GraphQLString},
date: {type:GraphQLString},
timestamp: {type:GraphQLString},
format: {type:GraphQLString},
reblog_key: {type:GraphQLString},
tags: {type:new GraphQLList(GraphQLString)},
bookmarklet: {type:GraphQLBoolean},
mobile: {type:GraphQLBoolean},
source_url: {type:GraphQLString},
source_title: {type:GraphQLString},
liked: {type:GraphQLBoolean},
state: {type:GraphQLString},
total_posts: {type:GraphQLInt},
note_count: {type:GraphQLInt},
title: {type:GraphQLString},
url: {type:GraphQLString},
author: {type:GraphQLString},
excerpt: {type:GraphQLString},
publisher: {type:GraphQLString},
photos: {type:new GraphQLList(tumblrPhotoType)},
description: {type:GraphQLString},
})
});

const tumblrPhotoType = require('./tumblrPhotoType');
Loading

0 comments on commit 6c3b546

Please sign in to comment.