How to use the nexus.intArg 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.

github keepforever / a-prisma2 / src / resolvers / Query.ts View on Github external
resolve: (_parent, _args, ctx) => {
                return ctx.photon.users.findMany();
            }
        });

        t.list.field('feedDecks', {
            type: 'Deck',
            resolve: (_parent, _args, ctx) => {
                return ctx.photon.decks.findMany();
            }
        });

        t.list.field('deckConnection', {
            type: 'Deck',
            args: {
                first: intArg(),
                last: stringArg()
            },
            resolve: (_parent, args, ctx) => {
                const { first, last } = args;
                return ctx.photon.decks.findMany({
                    first: first,
                    after: last
                });
            }
        });

        // t.list.field('feed', {
        //   type: 'Post',
        //   resolve: (_parent, _args, ctx) => {
        //     return ctx.photon.posts.findMany({
        //       where: { published: true },
github prisma-labs / nexus-prisma / examples / blog / src / schema / Query.ts View on Github external
definition(t) {
    t.crud.blogs({
      pagination: false,
    })
    t.crud.users({ filtering: true, alias: 'people' })
    t.crud.posts({ type: 'CustomPost', ordering: true, filtering: true })

    //
    // Examples showing custom resolvers
    //

    t.field('blog', {
      type: 'Blog',
      args: {
        id: intArg({ required: true }),
      },
      resolve(_root, args, ctx) {
        return ctx.photon.blogs
          .findOne({
            where: {
              id: args.id,
            },
          })
          .then(result => {
            if (result === null) {
              throw new Error(`No blog with id of "${args.id}"`)
            }
            return result
          })
      },
    })
github jferrettiboke / stripe-graphql / src / graphql / customers / Query.ts View on Github external
definition(t) {
    t.list.field("customers", {
      type: "Customer",
      args: {
        endingBefore: stringArg(),
        startingAfter: stringArg(),
        limit: intArg()
      },
      async resolve(
        root,
        { endingBefore, startingAfter, limit },
        context,
        info
      ) {
        let options = {};
        if (startingAfter) {
          options = { ...options, starting_after: startingAfter };
        }
        if (endingBefore) {
          options = { ...options, ending_before: endingBefore };
        }
        if (limit) {
          options = { ...options, limit };
github nodkz / conf-talks / articles / graphql / schema-build-ways / nexus.ts View on Github external
definition(t) {
    t.list.field('articles', {
      nullable: true,
      type: Article,
      args: {
        limit: intArg({ default: 3, required: true })
      },
      resolve: (_, args) => {
        const { limit } = args;
        return articles.slice(0, limit);
      },
    });
    t.list.field('authors', {
      nullable: true,
      type: Author,
      resolve: () => authors,
    });
  },
});
github Novvum / MarvelQL / packages / graphql / schema / types / Query.ts View on Github external
description: 'Fetches a single character by id.',
            args: {
                where: arg({ type: "CharacterWhereInput" }),
            },
            async resolve(_, args, ctx, info) {
                return await ctx.charactersModel.getOne(args.where);
            },
        });
        t.list.field("comics", {
            type: "Comic",
            nullable: true,
            description: 'Fetches a list of comics.',
            args: {
                where: arg({ type: "ComicWhereInput" }),
                orderBy: arg({ type: "ComicOrderBy" }),
                offset: intArg({ description: "Skips the specified number of resources in the result set." }),
                limit: intArg({ description: "Limit the result set to the specified number of resources." }),
            },
            async resolve(_, args, ctx, info) {
                return await ctx.comicsModel.getMany({
                    where: args.where,
                    orderBy: args.orderBy,
                    limit: args.limit,
                    offset: args.offset
                });
            },
        });
        t.field("getComic", {
            type: "Comic",
            nullable: true,
            description: 'Fetches a single comic by id.',
            args: {