Last active
July 2, 2018 22:10
-
-
Save mhaagens/b9ba0ee79201a872e27012b0c39f0621 to your computer and use it in GitHub Desktop.
Authentication and authorization using GraphQL Schema Directives: src/models/post.js
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
const { gql } = require("apollo-server"); | |
const mockPosts = [ | |
{ id: 1, title: "Helvetica and Times New Roman walk into a bar. Get out of here! shouts the bartender. We don't serve your type!", ownerId: 1 }, | |
{ id: 2, title: "Why do we tell actors to break a leg? Because every play has a cast.", ownerId: 2 }, | |
{ id: 3, title: "Did you hear about the mathematician who’s afraid of negative numbers? He'll stop at nothing to avoid them.", ownerId: 1 } | |
]; | |
module.exports.postDefs = gql` | |
extend type Query { | |
posts: [Post] @requireAuth | |
} | |
type Post { | |
id: Int | |
title: String | |
} | |
`; | |
module.exports.postResolvers = { | |
Query: { | |
posts: () => mockPosts | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment