How to use the nexus.arg 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 prisma-labs / nexus-prisma / src / publisher.ts View on Github external
inputType(
    customArg: CustomInputArg,
  ):
    | string
    | Nexus.core.NexusInputObjectTypeDef<string>
    | Nexus.core.NexusEnumTypeDef<string>
    | Nexus.core.NexusScalarTypeDef<string>
    | Nexus.core.NexusArgDef<any> {
    const typeName = customArg.type.name

    // If type is already published, just reference it
    if (this.isPublished(typeName)) {
      return Nexus.arg(
        dmmfFieldToNexusFieldConfig({
          ...customArg.arg.inputType,
          type: customArg.type.name,
        }),
      )
    }

    if (customArg.arg.inputType.kind === 'scalar') {
      return this.publishScalar(customArg.type.name)
    }

    if (customArg.arg.inputType.kind === 'enum') {
      return this.publishEnum(customArg.type.name)
    }

    const inputType = customArg.type as DMMF.Data.InputType
github arkhn / pyrog / server-v2 / src / types / Mutation.ts View on Github external
id: idArg({ required: true }),
      },
      resolve: deleteAttribute,
    })

    /*
     * INPUT
     */

    t.field('createInput', {
      type: 'Input',
      args: {
        attributeId: idArg({ required: true }),
        script: stringArg(),
        static: stringArg(),
        sql: arg({
          type: 'ColumnInput',
        }),
      },
      resolve: createInput,
    })

    t.field('deleteInput', {
      type: 'Input',
      args: {
        id: idArg({ required: true }),
      },
      resolve: deleteInput,
    })

    /*
    * COLUMN
github Novvum / MarvelQL / packages / graphql / schema / types / Query.ts View on Github external
type: "Event",
            nullable: true,
            description: 'Fetches a single event by id.',
            args: {
                where: arg({ type: "EventsWhereInput" }),
            },
            async resolve(_, args, ctx, info) {
                return await ctx.eventsModel.getOne(args.where);
            },
        });
        t.list.field("series", {
            type: "Series",
            nullable: true,
            description: 'Fetches a list of series.',
            args: {
                where: arg({ type: "SeriesWhereInput" }),
                orderBy: arg({ type: "SeriesOrderBy" }),
                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.seriesModel.getMany({
                    where: args.where,
                    orderBy: args.orderBy,
                    limit: args.limit,
                    offset: args.offset
                });
            },
        });
        t.field("getSeries", {
            type: "Series",
            nullable: true,
github este / este / packages / api / schema / user.ts View on Github external
definition(t) {
    t.string('name');
  },
});

export const SetUserThemePayload = objectType({
  nonNullDefaults: { output: false },
  name: 'SetUserThemePayload',
  definition(t) {
    t.field('user', { type: User });
  },
});

export const setUserTheme = mutationField('setUserTheme', {
  type: SetUserThemePayload,
  args: { input: arg({ type: SetUserThemeInput }) },
  resolve: (_root, { input }, context) =>
    context.models.user.setTheme(input.name || ''),
});
github arkhn / pyrog / server-v2 / src / types / Mutation.ts View on Github external
args: {
        columnId: idArg({ required: true }),
        join: arg({ type: 'JoinInput' }),
      },
      resolve: addJoinToColumn,
    })

    /*
    * JOIN
    */

    t.field('updateJoin', {
      type: 'Join',
      args: {
        joinId: idArg({ required: true }),
        data: arg({ type: 'JoinInput', required: true }),
      },
      resolve: updateJoin,
    })

    t.field('deleteJoin', {
      type: 'Join',
      args: {
        id: idArg({ required: true }),
      },
      resolve: deleteJoin,
    })
  },
})