Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 })
}
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 })
}
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);
}
}
}
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 })
}
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 })
}
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)
}
}