How to use the nexus.enumType function in nexus

To help you get started, we’ve selected a few nexus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github este / este / packages / api / schema / errors.ts View on Github external
import { enumType } from 'nexus';

// https://itnext.io/the-definitive-guide-to-handling-graphql-errors-e0c58b52b5e1

export const EmailError = enumType({
  name: 'EmailError',
  members: ['REQUIRED', 'EMAIL', 'ALREADY_EXISTS', 'NOT_EXISTS'],
});

export const URLError = enumType({
  name: 'URLError',
  members: ['REQUIRED', 'URL'],
});

export const PasswordError = enumType({
  name: 'PasswordError',
  members: ['REQUIRED', 'MIN_5_CHARS', 'MAX_1024_CHARS', 'WRONG_PASSWORD'],
});

export const Max140CharsError = enumType({
  name: 'Max140CharsError',
  members: ['REQUIRED', 'MAX_140_CHARS'],
});
github Novvum / MarvelQL / packages / graphql / schema / types / Story.ts View on Github external
});
    }
});
export const StoriesWhereInput = inputObjectType({
    name: "StoriesWhereInput",
    description: 'Optional filters for stories. See notes on individual inputs below.',
    definition(t) {
        t.field("modifiedSince", { type: "DateTime" });
        t.list.id("comics");
        t.list.id("series");
        t.list.id("events");
        t.list.id("creators");
        t.list.id("characters");
    }
});
export const StoriesOrderBy = enumType({
    name: "StoriesOrderBy",
    description: 'Order the result set by a field or fields. Multiple values are given priority in the order in which they are passed.',
    members: ['id_asc', 'id_desc', 'modified_asc', 'modified_desc'],
});
github Novvum / MarvelQL / packages / graphql / schema / types / Comic.ts View on Github external
}
        })
    }
})

export const ComicFormat = enumType({
    name: "ComicFormat",
    description: 'Return only series containing one or more comics with the specified format.',
    members: [{ description: 'Return only series containing one or more comics with the specified format of a magazine.', name: 'magazine', value: 'magazine' }, { description: 'Return only series containing one or more comics with the specified format of a trade paperback.', name: 'trade_paperback', value: 'trade_paperback' }, { description: 'Return only series containing one or more comics with the specified format of a hardcover.', name: 'hardcover', value: 'hardcover' }, { description: 'Return only series containing one or more comics with the specified format of a digest.', name: 'digest', value: 'digest' }, { description: 'Return only series containing one or more comics with the specified format of a graphic novel.', name: 'graphic_novel', value: 'graphic_novel' }, { description: 'Return only series containing one or more comics with the specified format of a comic.', name: 'comic', value: 'comic' }, { description: 'Return only series containing one or more comics with the specified format of a digital comic.', name: 'digital_comic', value: 'digital_comic' }, { description: 'Return only series containing one or more comics with the specified format of an infinite comic.', name: 'infinite_comic', value: 'infinite_comic' }],
});
export const ComicFormatType = enumType({
    name: "ComicFormatType",
    description: 'Filter by the issue format type (comic or collection).',
    members: ['comic', 'collection'],
});
export const ComicOrderBy = enumType({
    name: "ComicOrderBy",
    description: 'Order the result set by a field or fields. Multiple values are given priority in the order in which they are passed.',
    members: ['focDate_asc', 'onSaleDate_asc', 'title_asc', 'issueNumber_asc', 'modified_asc', 'focDate_desc', 'onSaleDate_desc', 'title_desc', 'issueNumber_desc', 'modified_desc'],
});
export const ComicWhereInput = inputObjectType({
    name: "ComicWhereInput",
    description: 'Optional filters for comics. See notes on individual inputs below.',
    definition(t) {
        t.field("format", {
            type: "ComicFormat",
            description: 'Filter by the issue format (e.g. comic, digital comic, hardcover).',
        });
        t.field("formatType", {
            type: "ComicFormatType",
            description: 'Filter by the issue format type (comic or collection).',
        });
github Novvum / MarvelQL / packages / graphql / schema / types / Creator.ts View on Github external
return res.results;
            }
        });
        t.list.field("events", {
            type: "Event",
            nullable: true,
            description: 'A list of events (Event Types) related to this creator',
            async resolve(parent, args, ctx) {
                const res = await ctx.api.get(`/creators/${parent.id}/events`);
                return res.results;
            }
        });
    }
});

export const CreatorOrderBy = enumType({
    name: "CreatorOrderBy",
    description: 'Order the result set by a field or fields. Multiple values are given priority in the order in which they are passed.',
    members: ['lastName_asc', 'firstName_asc', 'middleName_asc', 'suffix_asc', 'modified_asc', 'lastName_desc', 'firstName_desc', 'middleName_desc', 'suffix_desc', 'modified_desc'],
});

export const CreatorWhereInput = inputObjectType({
    name: "CreatorWhereInput",
    description: 'Optional filters for creators. See notes on individual inputs below.',
    definition(t) {
        t.string("firstName", { description: 'Filter by creator first name (e.g. Brian).' });
        t.string("middleName", { description: 'Filter by creator middle name (e.g. Michael).' });
        t.string("lastName", { description: 'Filter by creator last name (e.g. Bendis).' });
        t.string("suffix", { description: 'Filter by suffix or honorific (e.g. Jr., Sr.).' });
        t.string("nameStartsWith", { description: 'Filter by creator names that match critera (e.g. B, St L).' });
        t.string("firstNameStartsWith", { description: 'Filter by creator first names that match critera (e.g. B, St L).' });
        t.string("middleNameStartsWith", { description: 'Filter by creator middle names that match critera (e.g. Mi).' });
github prisma-labs / nexus-prisma / src / publisher.ts View on Github external
protected publishEnum(typeName: string) {
    const dmmfEnum = this.dmmf.getEnumType(typeName)

    this.markTypeAsPublished(typeName)

    return Nexus.enumType({
      name: typeName,
      members: dmmfEnum.values,
    })
  }
github Novvum / MarvelQL / packages / graphql / schema / types / Series.ts View on Github external
t.field("contains", {
            type: "ComicFormat",
            description: 'Return only series containing one or more comics with the specified format.',
        });
        t.field("seriesType", {
            type: "SeriesType",
            description: 'Filter the series by publication frequency type.',
        });
        t.list.id("comics", { description: 'Return only series which contain the specified comics (accepts a comma-separated list of ids).' });
        t.list.id("stories", { description: 'Return only series which contain the specified stories (accepts a comma-separated list of ids).' });
        t.list.id("events", { description: 'Return only series which have comics that take place during the specified events (accepts a comma-separated list of ids).' });
        t.list.id("creators", { description: 'Return only series which feature work by the specified creators (accepts a comma-separated list of ids).' });
        t.list.id("characters", { description: 'Return only series which feature the specified characters (accepts a comma-separated list of ids).' });
    }
});
export const SeriesOrderBy = enumType({
    name: "SeriesOrderBy",
    description: 'Order the result set by a field or fields. Multiple values are given priority in the order in which they are passed.',
    members: ['title_asc', 'modified_asc', 'startYear_asc', 'title_desc', 'modified_desc', 'startYear_desc'],
});
export const SeriesType = enumType({
    name: "SeriesType",
    description: 'Filter the series by publication frequency type.',
    members: [{ description: 'Filter the series with a collection publication frequency.', name: 'collection', value: 'collection' }, { description: 'Filter the series with a one shot publication frequency.', name: 'one_shot', value: 'one_shot' }, { description: 'Filter the series with a limited publication frequency.', name: 'limited', value: 'limited' }, { description: 'Filter the series with a ongoing publication frequency.', name: 'ongoing', value: 'ongoing' }],
});