UNPKG

@wepublish/api

Version:
103 lines 4.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GraphQLAuthorInput = exports.GraphQLAuthorLinkInput = exports.GraphQLAuthorConnection = exports.GraphQLAuthorSort = exports.GraphQLAuthorFilter = exports.GraphQLAuthor = exports.GraphQLAuthorLink = void 0; const tslib_1 = require("tslib"); const graphql_1 = require("graphql"); const author_1 = require("../db/author"); const common_1 = require("./common"); const image_1 = require("./image"); const slug_1 = require("./slug"); const api_1 = require("../../../richtext-api/src"); const graphql_scalars_1 = require("graphql-scalars"); const utility_1 = require("../utility"); const tag_1 = require("./tag/tag"); exports.GraphQLAuthorLink = new graphql_1.GraphQLObjectType({ name: 'AuthorLink', fields: { title: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }, url: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) } } }); exports.GraphQLAuthor = new graphql_1.GraphQLObjectType({ name: 'Author', fields: { id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) }, createdAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) }, modifiedAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) }, name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }, slug: { type: new graphql_1.GraphQLNonNull(slug_1.GraphQLSlug) }, url: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString), resolve: (0, utility_1.createProxyingResolver)((author, _, { urlAdapter }) => { return urlAdapter.getAuthorURL(author); }) }, links: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLAuthorLink)) }, bio: { type: api_1.GraphQLRichText }, jobTitle: { type: graphql_1.GraphQLString }, image: { type: image_1.GraphQLImage, resolve: (0, utility_1.createProxyingResolver)(({ imageID }, args, { loaders }) => { return imageID ? loaders.images.load(imageID) : null; }) }, 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: { authors: { some: { authorId: id } } } }); return tags; })) } } }); exports.GraphQLAuthorFilter = new graphql_1.GraphQLInputObjectType({ name: 'AuthorFilter', fields: { name: { type: graphql_1.GraphQLString }, tagIds: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)) } } }); exports.GraphQLAuthorSort = new graphql_1.GraphQLEnumType({ name: 'AuthorSort', values: { CREATED_AT: { value: author_1.AuthorSort.CreatedAt }, MODIFIED_AT: { value: author_1.AuthorSort.ModifiedAt }, NAME: { value: author_1.AuthorSort.Name } } }); exports.GraphQLAuthorConnection = new graphql_1.GraphQLObjectType({ name: 'AuthorConnection', fields: { nodes: { type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLAuthor))) }, pageInfo: { type: new graphql_1.GraphQLNonNull(common_1.GraphQLPageInfo) }, totalCount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) } } }); exports.GraphQLAuthorLinkInput = new graphql_1.GraphQLInputObjectType({ name: 'AuthorLinkInput', fields: { title: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }, url: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) } } }); exports.GraphQLAuthorInput = new graphql_1.GraphQLInputObjectType({ name: 'AuthorInput', fields: { name: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }, slug: { type: new graphql_1.GraphQLNonNull(slug_1.GraphQLSlug) }, links: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.GraphQLAuthorLinkInput)) }, bio: { type: api_1.GraphQLRichText }, jobTitle: { type: graphql_1.GraphQLString }, imageID: { type: graphql_1.GraphQLID }, tagIds: { type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)) } } }); //# sourceMappingURL=author.js.map