import { AuthInfo } from "@pie-api-gcp/shared/auth"; import { gql } from "apollo-server"; import { GraphQLSchemaFactory, GraphQLSchemaElements } from "../types"; const Schema = gql` type SemVer { major: Int minor: Int patch: Int prerelease: JSON } enum ReleaseTypeEnum { major minor patch } enum PreReleaseTypeEnum { premajor preminor prepatch prerelease } `; export const schemaFactory: GraphQLSchemaFactory = async (token: AuthInfo): Promise => ({ typeDefs: [Schema], resolvers: { Entity: { // tslint:disable-next-line:function-name __resolveType(obj) { switch (obj.type) { case "CLIENT": { return "ApiClient"; } case "ORGANIZATION": { return "Organization"; } case "COLLECTION": { return "Collection"; } case "CONTENTITEM": { return "ContentItem"; } case "PIECONTENT": { return "Stimulus"; } default: { return null; } } }, }, }, }); export default schemaFactory;