mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-10 21:00:37 -05:00
38 lines
660 B
JavaScript
38 lines
660 B
JavaScript
const { UserInputError, gql } = require("apollo-server-express")
|
|
const Link = require("../mongoose-models/link")
|
|
|
|
const typeDef = gql`
|
|
extend type Query {
|
|
links: [Link!]!
|
|
}
|
|
enum LinkType {
|
|
DISCORD
|
|
GUIDE
|
|
MISC
|
|
}
|
|
type Link {
|
|
title: String!
|
|
url: String!
|
|
description: String!
|
|
type: LinkType!
|
|
}
|
|
`
|
|
const resolvers = {
|
|
Query: {
|
|
links: (root, args) => {
|
|
return Link.find({})
|
|
.sort({ title: "asc" })
|
|
.catch(e => {
|
|
throw new UserInputError(e.message, {
|
|
invalidArgs: args,
|
|
})
|
|
})
|
|
},
|
|
},
|
|
}
|
|
|
|
module.exports = {
|
|
Link: typeDef,
|
|
linkResolvers: resolvers,
|
|
}
|