@nestjs/graphql#ObjectTypeOptions TypeScript Examples

The following examples show how to use @nestjs/graphql#ObjectTypeOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: node-type.decorator.ts    From nestjs-relay with MIT License 6 votes vote down vote up
export function NodeType<T extends AnyConstructor<T>>(
  nameOrOptions?: string | ObjectTypeOptions,
  objectTypeOptions?: ObjectTypeOptions,
): ClassDecorator {
  // eslint-disable-next-line @typescript-eslint/ban-types
  return (target: Function) => {
    const [name, options = {}] = isString(nameOrOptions)
      ? [nameOrOptions, objectTypeOptions]
      : [target.name, nameOrOptions];

    const interfaces = options.implements ? [].concat(options.implements as never) : [];

    const nodeOptions: ObjectTypeOptions = {
      ...options,
      implements: interfaces.concat(NodeInterface as never),
    };

    MetadataStorage.addClassMetadata({ name, target });
    ObjectType(name, nodeOptions)(target);
  };
}