How to use the type-graphql.Arg function in type-graphql

To help you get started, we’ve selected a few type-graphql 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 wemaintain / auto-relay / packages / core / src / graphql / dynamic-object.factory.ts View on Github external
functionName: string,
    sdlName: string | symbol,
    Connection: new () => Relay.Connection,
    options?: RelayedConnectionOptions,
  ): void {
    const fieldOptions = options && options.field
    // Ignore the undefined options as it is the edge that needs to be nullable,
    // Not ourself
    if (fieldOptions && fieldOptions.nullable) fieldOptions.nullable = undefined

    // And we ensure our target[getterName] is recognized by GQL under target{}
    Reflect.defineMetadata('design:paramtypes', [String, Number, String, Number], target, functionName)
    Arg('after', () => String, { nullable: true })(target, functionName, 0)
    Arg('first', () => Number, { nullable: true })(target, functionName, 1)
    Arg('before', () => String, { nullable: true })(target, functionName, 2)
    Arg('last', () => Number, { nullable: true })(target, functionName, 3)
    Field(() => Connection, { name: `${String(sdlName)}`, ...fieldOptions })(target, functionName, { value: true })
  }
github wemaintain / auto-relay / packages / core / src / graphql / dynamic-object.factory.ts View on Github external
public declareFunctionAsRelayInSDL(
    target: any,
    functionName: string,
    sdlName: string | symbol,
    Connection: new () => Relay.Connection,
    options?: RelayedConnectionOptions,
  ): void {
    const fieldOptions = options && options.field
    // Ignore the undefined options as it is the edge that needs to be nullable,
    // Not ourself
    if (fieldOptions && fieldOptions.nullable) fieldOptions.nullable = undefined

    // And we ensure our target[getterName] is recognized by GQL under target{}
    Reflect.defineMetadata('design:paramtypes', [String, Number, String, Number], target, functionName)
    Arg('after', () => String, { nullable: true })(target, functionName, 0)
    Arg('first', () => Number, { nullable: true })(target, functionName, 1)
    Arg('before', () => String, { nullable: true })(target, functionName, 2)
    Arg('last', () => Number, { nullable: true })(target, functionName, 3)
    Field(() => Connection, { name: `${String(sdlName)}`, ...fieldOptions })(target, functionName, { value: true })
  }
github wemaintain / auto-relay / packages / core / src / services / relay-query.service.ts View on Github external
protected registerArgs(target: Object, propertyKey: string, options?: RelayedQueryOptions,) {
    const ConnectionArgsThunk = Container.get(CONNECTIONARGS_OBJECT);
    const ConnectionArgs = ConnectionArgsThunk();

    if (options && options.paginationInputType) {
      // We want our pagination to be a named input rather than args
      const name = typeof options.paginationInputType === 'string' ? options.paginationInputType : 'pagination';
      Reflect.defineMetadata('autorelay:connectionArgs:key', name, target, propertyKey)
      Arg(name, () => ConnectionArgs, { nullable: true })(target, propertyKey, 99999999);
    } else {
      Args(() => ConnectionArgs)(target, propertyKey, 99999999);
    }
  }
}
github wemaintain / auto-relay / packages / core / src / graphql / dynamic-object.factory.ts View on Github external
public declareFunctionAsRelayInSDL(
    target: any,
    functionName: string,
    sdlName: string | symbol,
    Connection: new () => Relay.Connection,
    options?: RelayedConnectionOptions,
  ): void {
    const fieldOptions = options && options.field
    // Ignore the undefined options as it is the edge that needs to be nullable,
    // Not ourself
    if (fieldOptions && fieldOptions.nullable) fieldOptions.nullable = undefined

    // And we ensure our target[getterName] is recognized by GQL under target{}
    Reflect.defineMetadata('design:paramtypes', [String, Number, String, Number], target, functionName)
    Arg('after', () => String, { nullable: true })(target, functionName, 0)
    Arg('first', () => Number, { nullable: true })(target, functionName, 1)
    Arg('before', () => String, { nullable: true })(target, functionName, 2)
    Arg('last', () => Number, { nullable: true })(target, functionName, 3)
    Field(() => Connection, { name: `${String(sdlName)}`, ...fieldOptions })(target, functionName, { value: true })
  }
github wemaintain / auto-relay / packages / core / src / graphql / dynamic-object.factory.ts View on Github external
target: any,
    functionName: string,
    sdlName: string | symbol,
    Connection: new () => Relay.Connection,
    options?: RelayedConnectionOptions,
  ): void {
    const fieldOptions = options && options.field
    // Ignore the undefined options as it is the edge that needs to be nullable,
    // Not ourself
    if (fieldOptions && fieldOptions.nullable) fieldOptions.nullable = undefined

    // And we ensure our target[getterName] is recognized by GQL under target{}
    Reflect.defineMetadata('design:paramtypes', [String, Number, String, Number], target, functionName)
    Arg('after', () => String, { nullable: true })(target, functionName, 0)
    Arg('first', () => Number, { nullable: true })(target, functionName, 1)
    Arg('before', () => String, { nullable: true })(target, functionName, 2)
    Arg('last', () => Number, { nullable: true })(target, functionName, 3)
    Field(() => Connection, { name: `${String(sdlName)}`, ...fieldOptions })(target, functionName, { value: true })
  }
github wemaintain / auto-relay / packages / sorting / src / graphql / graphql.generator.ts View on Github external
public generateForType(
    type: ClassType,
    target: ClassType,
    propertyKey: string,
  ): void {
    const Enum = this.createEnum(type, target, propertyKey)

    if (Enum) {
      const OrderingValue = orderingValueGQLFactory(type.name, Enum)
      Arg("order", () => [OrderingValue], { nullable: true })(target, propertyKey, 999999998)
    }
  }