Created
June 30, 2016 01:53
-
-
Save ramsaylanier/cc7e76e6ef75284b268072be30fd7537 to your computer and use it in GitHub Desktop.
Resolver Functions for WordExpress
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 Connectors from './connectors'; | |
import { publicSettings, privateSettings } from '../settings/settings'; | |
const resolveFunctions = { | |
Query: { | |
settings(){ | |
return publicSettings | |
}, | |
posts(_, args){ | |
return Connectors.getPosts(args).then( res=> { | |
return res; | |
}); | |
}, | |
menus(_, {name}){ | |
return Connectors.getMenu(name); | |
}, | |
page(_, {name}){ | |
return Connectors.getPostByName(name); | |
}, | |
postmeta(_, {postId}){ | |
return Connectors.getPostmeta(postId); | |
} | |
}, | |
Post: { | |
layout(post){ | |
return Connectors.getPostLayout(post.id) | |
}, | |
post_meta(post, keys){ | |
return Connectors.getPostmeta(post.id, keys) | |
}, | |
thumbnail(post){ | |
return Connectors.getPostThumbnail(post.id) | |
} | |
}, | |
Postmeta: { | |
connecting_post(postmeta){ | |
return Connectors.getPostById(postmeta.meta_value) | |
} | |
}, | |
Menu: { | |
items(menu){ | |
console.log(menu.items); | |
return menu.items; | |
} | |
}, | |
MenuItem: { | |
navitem(menuItem){ | |
return Connectors.getPostById(menuItem.linkedId) | |
}, | |
children(menuItem){ | |
return menuItem.children | |
} | |
} | |
} | |
export default resolveFunctions; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment