stacker.news/api/resolvers/index.js

48 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-03-25 19:29:24 +00:00
import user from './user'
import message from './message'
2021-04-12 18:05:09 +00:00
import item from './item'
2021-04-30 21:42:51 +00:00
import wallet from './wallet'
2021-06-27 03:09:39 +00:00
import lnurl from './lnurl'
2021-08-17 18:15:24 +00:00
import notifications from './notifications'
2021-10-12 23:49:04 +00:00
import invite from './invite'
2022-02-17 17:23:43 +00:00
import sub from './sub'
2022-05-12 18:44:21 +00:00
import upload from './upload'
2023-05-18 23:41:56 +00:00
import growth from './growth'
2022-10-20 22:44:44 +00:00
import search from './search'
2022-12-08 00:04:02 +00:00
import rewards from './rewards'
2022-12-19 22:27:52 +00:00
import referrals from './referrals'
import price from './price'
2023-07-27 00:18:42 +00:00
import { GraphQLJSONObject as JSONObject } from 'graphql-type-json'
2023-06-20 01:26:34 +00:00
import admin from './admin'
2023-07-27 00:18:42 +00:00
import { GraphQLScalarType, Kind } from 'graphql'
const date = new GraphQLScalarType({
name: 'Date',
description: 'Date custom scalar type',
serialize (value) {
if (value instanceof Date) {
return value.toISOString() // Convert outgoing Date to string for JSON
} else if (typeof value === 'string') {
return value
}
throw Error('GraphQL Date Scalar serializer expected a `Date` object got `' + typeof value + '` ' + value)
},
parseValue (value) {
if (typeof value === 'string') {
return new Date(value) // Convert incoming string to Date
}
throw new Error('GraphQL Date Scalar parser expected a `string`')
},
parseLiteral (ast) {
if (ast.kind === Kind.STRING) {
// Convert hard-coded AST string to integer and then to Date
return new Date(ast.value)
}
// Invalid hard-coded value (not an integer)
return null
}
})
2021-03-25 19:29:24 +00:00
2022-05-12 18:44:21 +00:00
export default [user, item, message, wallet, lnurl, notifications, invite, sub,
2023-07-27 00:18:42 +00:00
upload, search, growth, rewards, referrals, price, admin, { JSONObject }, { Date: date }]