UNPKG

@wepublish/api

Version:
92 lines 4.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GraphQLEventSort = exports.GraphQLEventFilter = exports.GraphQLEventConnection = exports.GraphQLEvent = exports.GraphQLEventStatus = void 0; const tslib_1 = require("tslib"); const client_1 = require("@prisma/client"); const graphql_1 = require("graphql"); const graphql_scalars_1 = require("graphql-scalars"); const utility_1 = require("../../utility"); const common_1 = require("../common"); const image_1 = require("../image"); const api_1 = require("../../../../richtext-api/src"); const tag_1 = require("../tag/tag"); const event_query_1 = require("./event.query"); exports.GraphQLEventStatus = new graphql_1.GraphQLEnumType({ name: 'EventStatus', values: { CANCELLED: { value: client_1.EventStatus.Cancelled }, RESCHEDULED: { value: client_1.EventStatus.Rescheduled }, POSTPONED: { value: client_1.EventStatus.Postponed }, SCHEDULED: { value: client_1.EventStatus.Scheduled } } }); exports.GraphQLEvent = new graphql_1.GraphQLObjectType({ name: 'Event', fields: { id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) }, name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }, status: { type: new graphql_1.GraphQLNonNull(exports.GraphQLEventStatus) }, description: { type: api_1.GraphQLRichText }, location: { type: graphql_1.GraphQLString }, startsAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) }, endsAt: { type: graphql_scalars_1.GraphQLDateTime }, externalSourceId: { type: graphql_1.GraphQLString }, externalSourceName: { type: graphql_1.GraphQLString }, tags: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(tag_1.GraphQLTag)), resolve: (0, utility_1.createProxyingResolver)(({ id }, _, { prisma: { tag } }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { const tags = yield tag.findMany({ where: { events: { some: { eventId: id } } } }); return tags; })) }, image: { type: image_1.GraphQLImage, resolve: (0, utility_1.createProxyingResolver)(({ imageId }, args, { loaders }) => { return imageId ? loaders.images.load(imageId) : null; }) }, url: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString), resolve: (0, utility_1.createProxyingResolver)((event, args, { urlAdapter }) => { return urlAdapter.getEventURL(event); }) } } }); exports.GraphQLEventConnection = new graphql_1.GraphQLObjectType({ name: 'EventConnection', fields: { nodes: { type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLEvent))) }, pageInfo: { type: new graphql_1.GraphQLNonNull(common_1.GraphQLPageInfo) }, totalCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) } } }); exports.GraphQLEventFilter = new graphql_1.GraphQLInputObjectType({ name: 'EventFilter', fields: { upcomingOnly: { type: graphql_1.GraphQLBoolean }, from: { type: graphql_scalars_1.GraphQLDateTime }, to: { type: graphql_scalars_1.GraphQLDateTime }, tags: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)) }, name: { type: graphql_1.GraphQLString }, location: { type: graphql_1.GraphQLString } } }); exports.GraphQLEventSort = new graphql_1.GraphQLEnumType({ name: 'EventSort', values: { STARTS_AT: { value: event_query_1.EventSort.StartsAt }, ENDS_AT: { value: event_query_1.EventSort.EndsAt }, CREATED_AT: { value: event_query_1.EventSort.CreatedAt }, MODIFIED_AT: { value: event_query_1.EventSort.ModifiedAt } } }); //# sourceMappingURL=event.js.map