How to use the nexus.stringArg 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 keepforever / a-prisma2 / src / resolvers / Query.ts View on Github external
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 / photonjs / examples / typescript / graphql-apollo-server / src / index.ts View on Github external
} as any,
      resolve: (parent, { name, email }, ctx) => {
        return ctx.photon.users.create({
          data: {
            name,
            email,
          },
        })
      },
    })

    t.field('createDraft', {
      type: 'Post',
      args: {
        title: stringArg(),
        content: stringArg({ nullable: true }),
        authorEmail: stringArg(),
      } as any,
      resolve: (parent, { title, content, authorEmail }, ctx) => {
        return ctx.photon.posts.create({
          data: {
            title,
            content,
            published: false,
            // author: {
            //   connect: { email: authorEmail },
            // },
          },
        })
      },
    })
github prisma / prisma-examples / javascript / graphql / src / index.js View on Github external
definition(t) {
    t.crud.createOneUser({ alias: 'signupUser' })
    t.crud.deleteOnePost()

    t.field('createDraft', {
      type: 'Post',
      args: {
        title: stringArg(),
        content: stringArg({ nullable: true }),
        authorEmail: stringArg(),
      },
      resolve: (_, { title, content, authorEmail }, ctx) => {
        return ctx.photon.posts.create({
          data: {
            title,
            content,
            published: false,
            author: {
              connect: { email: authorEmail },
            },
          },
        })
      },
    })
github prisma / prisma-examples / typescript / graphql-apollo-server / src / schema.ts View on Github external
alias: 'post',
    })

    t.list.field('feed', {
      type: 'Post',
      resolve: (_, args, ctx) => {
        return ctx.photon.posts.findMany({
          where: { published: true },
        })
      },
    })

    t.list.field('filterPosts', {
      type: 'Post',
      args: {
        searchString: stringArg({ nullable: true }),
      },
      resolve: (_, { searchString }, ctx) => {
        return ctx.photon.posts.findMany({
          where: {
            OR: [
              { title: { contains: searchString } },
              { content: { contains: searchString } },
            ],
          },
        })
      },
    })
  },
})
github prisma / prisma-examples / typescript / graphql / src / schema.ts View on Github external
definition(t) {
    t.crud.createOneUser({ alias: 'signupUser' })
    t.crud.deleteOnePost()

    t.field('createDraft', {
      type: 'Post',
      args: {
        title: stringArg({ nullable: false }),
        content: stringArg(),
        authorEmail: stringArg(),
      },
      resolve: (_, { title, content, authorEmail }, ctx) => {
        return ctx.photon.posts.create({
          data: {
            title,
            content,
            published: false,
            author: {
              connect: { email: authorEmail },
            },
          },
        })
      },
    })
github prisma / prisma-examples / typescript / graphql / src / index.ts View on Github external
alias: 'post',
    })

    t.list.field('feed', {
      type: 'Post',
      resolve: (_, args, ctx) => {
        return ctx.photon.posts.findMany({
          where: { published: true },
        })
      },
    })

    t.list.field('filterPosts', {
      type: 'Post',
      args: {
        searchString: stringArg({ nullable: true }),
      },
      resolve: (_, { searchString }, ctx) => {
        return ctx.photon.posts.findMany({
          where: {
            OR: [
              { title: { contains: searchString } },
              { content: { contains: searchString } },
            ],
          },
        })
      },
    })
  },
})
github keepforever / a-prisma2 / src / resolvers / Mutation.ts View on Github external
definition(t) {
        t.field('signup', {
            type: 'AuthPayload',
            args: {
                name: stringArg({ nullable: true }),
                email: stringArg(),
                password: stringArg(),
                isAdmin: booleanArg(),
                arenaHandle: stringArg()
            },
            resolve: async (
                _parent,
                { name, email, password, arenaHandle },
                ctx
            ) => {
                const hashedPassword = await hash(password, 10);
                const user = await ctx.photon.users.create({
                    data: {
                        name,
                        email,
                        arenaHandle,
                        password: hashedPassword
                    }
                });
                return {
github prisma-labs / nexus-prisma / examples / src / resolvers / Mutation.ts View on Github external
t.field('deletePost', {
      type: 'Post',
      nullable: true,
      args: {
        id: idArg(),
      },
      resolve: (parent, args, ctx) => {
        return ctx.prisma.deletePost({ id: args.id })
      },
    })

    t.field('signupUser', {
      type: 'User',
      args: {
        name: stringArg(),
        email: stringArg(),
      },
      resolve: (parent, { name, email }, ctx) => {
        return ctx.prisma.createUser({ name, email })
      },
    })

    t.field('createDraft', {
      type: 'Post',
      args: {
        title: stringArg(),
        content: stringArg(),
        authorEmail: stringArg(),
      },
      resolve: (parent, { title, content, authorEmail }, ctx) => {
        return ctx.prisma.createPost({
          title,
github prisma / prisma-examples / typescript / graphql / src / schema.ts View on Github external
alias: 'post',
    })

    t.list.field('feed', {
      type: 'Post',
      resolve: (_parent, _args, ctx) => {
        return ctx.photon.posts.findMany({
          where: { published: true },
        })
      },
    })

    t.list.field('filterPosts', {
      type: 'Post',
      args: {
        searchString: stringArg({ nullable: true }),
      },
      resolve: (_, { searchString }, ctx) => {
        return ctx.photon.posts.findMany({
          where: {
            OR: [
              { title: { contains: searchString } },
              { content: { contains: searchString } },
            ],
          },
        })
      },
    })
  },
})
github prisma / prisma-examples / typescript / graphql / src / index.ts View on Github external
definition(t) {
    t.crud.createOneUser({ alias: 'signupUser' })
    t.crud.deleteOnePost()

    t.field('createDraft', {
      type: 'Post',
      args: {
        title: stringArg(),
        content: stringArg({ nullable: true }),
        authorEmail: stringArg(),
      },
      resolve: (_, { title, content, authorEmail }, ctx) => {
        return ctx.photon.posts.create({
          data: {
            title,
            content,
            published: false,
            author: {
              connect: { email: authorEmail },
            },
          },
        })
      },
    })