<commit_before>import {
  GraphQLArgumentConfig,
  GraphQLFieldConfig,
  GraphQLInputType,
  GraphQLOutputType,
  GraphQLResolveInfo,
  GraphQLFieldConfigArgumentMap,
} from 'graphql';
import * as graphql from './graphql';
import { InputTypeComposer } from './InputTypeComposer';
import { SchemaComposer } from './SchemaComposer';
import {
  ObjectTypeComposerArgumentConfig,
  ObjectTypeComposerArgumentConfigMapDefinition,
  ObjectTypeComposerArgumentConfigMap,
  ObjectTypeComposer,
  ObjectTypeComposerArgumentConfigAsObjectDefinition,
  ObjectTypeComposerArgumentConfigDefinition,
  ArgsMap,
} from './ObjectTypeComposer';
import { Thunk, Extensions } from './utils/definitions';
import { ProjectionType } from './utils/projection';
import {
  ComposeOutputTypeDefinition,
  ComposeInputType,
  ComposeOutputType,
  ComposeInputTypeDefinition,
  ComposeNamedOutputType,
  ComposeNamedInputType,
} from './utils/typeHelpers';

export type ResolverKinds = 'query' | 'mutation' | 'subscription';

export type ResolverDefinition<TSource, TContext, TArgs = ArgsMap> = {
  type?: Thunk<
    | ComposeOutputType<TContext>
    | ComposeOutputTypeDefinition<TContext>
    | Resolver<any, TContext, any>
  >;
  resolve?: ResolverRpCb<TSource, TContext, TArgs>;
  args?: ObjectTypeComposerArgumentConfigMapDefinition<TArgs>;
  name?: string;
  displayName?: string;
  kind?: ResolverKinds;
  description?: string;
  projection?: ProjectionType;
  parent?: Resolver<any, TContext, any>;
  extensions?: Extensions;
};

export type ResolverResolveParams<TSource, TContext, TArgs = ArgsMap> = {
  source: TSource;
  args: TArgs;
  context: TContext;
  info: GraphQLResolveInfo;
  projection: Partial<ProjectionType>;
  [opt: string]: any;
};

export type ResolverFilterArgFn<TSource, TContext, TArgs = ArgsMap> = (
  query: any,
  value: any,
  resolveParams: ResolverResolveParams<TSource, TContext, TArgs>
) => any;

export type ResolverFilterArgConfigDefinition<TSource, TContext, TArgs = ArgsMap> = {
  name: string;
  type: ComposeInputTypeDefinition;
  description?: string | null | void;
  query?: ResolverFilterArgFn<TSource, TContext, TArgs>;
  filterTypeNameFallback?: string;
  defaultValue?: any;
};

export type ResolverSortArgFn<TSource, TContext, TArgs = ArgsMap> = (
  resolveParams: ResolverResolveParams<TSource, TContext, TArgs>
) => any;

export type ResolverSortArgConfig<TSource, TContext, TArgs = ArgsMap> = {
  name: string;
  sortTypeNameFallback?: string;
  // value also can be an `Object`, but flow does not understande union with object and function
  // see https://github.com/facebook/flow/issues/1948
  value:
    | { [key: string]: any }
    | ResolverSortArgFn<TSource, TContext, TArgs>
    | string
    | number
    | boolean
    | any[];
  deprecationReason?: string | null;
  description?: string | null;
};

export type ResolverWrapCb<
  TNewSource,
  TPrevSource,
  TContext,
  TNewArgs = ArgsMap,
  TPrevArgs = ArgsMap
> = (
  newResolver: Resolver<TNewSource, TContext, TNewArgs>,
  prevResolver: Resolver<TPrevSource, TContext, TPrevArgs>
) => Resolver<TNewSource, TContext, TNewArgs>;

export type ResolverRpCb<TSource, TContext, TArgs = ArgsMap> = (
  resolveParams: ResolverResolveParams<TSource, TContext, TArgs>
) => Promise<any> | any;
export type ResolverNextRpCb<TSource, TContext, TArgs = ArgsMap> = (
  next: ResolverRpCb<TSource, TContext, TArgs>
) => ResolverRpCb<TSource, TContext, TArgs>;

export type ResolverDebugOpts = {
  showHidden?: boolean;
  depth?: number;
  colors?: boolean;
};

export type ResolverMiddleware<TSource, TContext, TArgs = ArgsMap> = (
  resolve: (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => any,
  source: TSource,
  args: TArgs,
  context: TContext,
  info: GraphQLResolveInfo
) => any;

/**
 * The most interesting class in `graphql-compose`. The main goal of `Resolver` is to keep available resolve methods for Type and use them for building relation with other types.
 */
export class Resolver<TSource = any, TContext = any, TArgs = ArgsMap, TReturn = any> {
  public schemaComposer: SchemaComposer<TContext>;
  public type: ComposeOutputType<TContext>;
  public args: ObjectTypeComposerArgumentConfigMap<any>;
  public name: string;
  public displayName: string | void;
  public kind: ResolverKinds | void;
  public description: string | void;
  public parent: Resolver<TSource, TContext, any> | void;
  public resolve: (
    resolveParams: Partial<ResolverResolveParams<TSource, TContext, TArgs>>
  ) => Promise<any> | any;

  constructor(
    opts: ResolverDefinition<TSource, TContext, TArgs>,
    schemaComposer: SchemaComposer<TContext>
  );

  /**
   * -----------------------------------------------
   * Output type methods
   * -----------------------------------------------
   */

  public getType(): GraphQLOutputType;

  public getTypeName(): string;<commit_msg>fix(Resolver): add extensions property to TypeScript definition<commit_after>import {
  GraphQLArgumentConfig,
  GraphQLFieldConfig,
  GraphQLInputType,
  GraphQLOutputType,
  GraphQLResolveInfo,
  GraphQLFieldConfigArgumentMap,
} from 'graphql';
import * as graphql from './graphql';
import { InputTypeComposer } from './InputTypeComposer';
import { SchemaComposer } from './SchemaComposer';
import {
  ObjectTypeComposerArgumentConfig,
  ObjectTypeComposerArgumentConfigMapDefinition,
  ObjectTypeComposerArgumentConfigMap,
  ObjectTypeComposer,
  ObjectTypeComposerArgumentConfigAsObjectDefinition,
  ObjectTypeComposerArgumentConfigDefinition,
  ArgsMap,
} from './ObjectTypeComposer';
import { Thunk, Extensions } from './utils/definitions';
import { ProjectionType } from './utils/projection';
import {
  ComposeOutputTypeDefinition,
  ComposeInputType,
  ComposeOutputType,
  ComposeInputTypeDefinition,
  ComposeNamedOutputType,
  ComposeNamedInputType,
} from './utils/typeHelpers';

export type ResolverKinds = 'query' | 'mutation' | 'subscription';

export type ResolverDefinition<TSource, TContext, TArgs = ArgsMap> = {
  type?: Thunk<
    | ComposeOutputType<TContext>
    | ComposeOutputTypeDefinition<TContext>
    | Resolver<any, TContext, any>
  >;
  resolve?: ResolverRpCb<TSource, TContext, TArgs>;
  args?: ObjectTypeComposerArgumentConfigMapDefinition<TArgs>;
  name?: string;
  displayName?: string;
  kind?: ResolverKinds;
  description?: string;
  projection?: ProjectionType;
  parent?: Resolver<any, TContext, any>;
  extensions?: Extensions;
};

export type ResolverResolveParams<TSource, TContext, TArgs = ArgsMap> = {
  source: TSource;
  args: TArgs;
  context: TContext;
  info: GraphQLResolveInfo;
  projection: Partial<ProjectionType>;
  [opt: string]: any;
};

export type ResolverFilterArgFn<TSource, TContext, TArgs = ArgsMap> = (
  query: any,
  value: any,
  resolveParams: ResolverResolveParams<TSource, TContext, TArgs>
) => any;

export type ResolverFilterArgConfigDefinition<TSource, TContext, TArgs = ArgsMap> = {
  name: string;
  type: ComposeInputTypeDefinition;
  description?: string | null | void;
  query?: ResolverFilterArgFn<TSource, TContext, TArgs>;
  filterTypeNameFallback?: string;
  defaultValue?: any;
};

export type ResolverSortArgFn<TSource, TContext, TArgs = ArgsMap> = (
  resolveParams: ResolverResolveParams<TSource, TContext, TArgs>
) => any;

export type ResolverSortArgConfig<TSource, TContext, TArgs = ArgsMap> = {
  name: string;
  sortTypeNameFallback?: string;
  // value also can be an `Object`, but flow does not understande union with object and function
  // see https://github.com/facebook/flow/issues/1948
  value:
    | { [key: string]: any }
    | ResolverSortArgFn<TSource, TContext, TArgs>
    | string
    | number
    | boolean
    | any[];
  deprecationReason?: string | null;
  description?: string | null;
};

export type ResolverWrapCb<
  TNewSource,
  TPrevSource,
  TContext,
  TNewArgs = ArgsMap,
  TPrevArgs = ArgsMap
> = (
  newResolver: Resolver<TNewSource, TContext, TNewArgs>,
  prevResolver: Resolver<TPrevSource, TContext, TPrevArgs>
) => Resolver<TNewSource, TContext, TNewArgs>;

export type ResolverRpCb<TSource, TContext, TArgs = ArgsMap> = (
  resolveParams: ResolverResolveParams<TSource, TContext, TArgs>
) => Promise<any> | any;
export type ResolverNextRpCb<TSource, TContext, TArgs = ArgsMap> = (
  next: ResolverRpCb<TSource, TContext, TArgs>
) => ResolverRpCb<TSource, TContext, TArgs>;

export type ResolverDebugOpts = {
  showHidden?: boolean;
  depth?: number;
  colors?: boolean;
};

export type ResolverMiddleware<TSource, TContext, TArgs = ArgsMap> = (
  resolve: (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => any,
  source: TSource,
  args: TArgs,
  context: TContext,
  info: GraphQLResolveInfo
) => any;

/**
 * The most interesting class in `graphql-compose`. The main goal of `Resolver` is to keep available resolve methods for Type and use them for building relation with other types.
 */
export class Resolver<TSource = any, TContext = any, TArgs = ArgsMap, TReturn = any> {
  public schemaComposer: SchemaComposer<TContext>;
  public type: ComposeOutputType<TContext>;
  public args: ObjectTypeComposerArgumentConfigMap<any>;
  public name: string;
  public displayName: string | void;
  public kind: ResolverKinds | void;
  public description: string | void;
  public parent: Resolver<TSource, TContext, any> | void;
  public extensions: Extensions | void;
  public resolve: (
    resolveParams: Partial<ResolverResolveParams<TSource, TContext, TArgs>>
  ) => Promise<any> | any;

  constructor(
    opts: ResolverDefinition<TSource, TContext, TArgs>,
    schemaComposer: SchemaComposer<TContext>
  );

  /**
   * -----------------------------------------------
   * Output type methods
   * -----------------------------------------------
   */

  public getType(): GraphQLOutputType;

  public getTypeName(): string;
{'fraction_non_alphanumeric': 0.12309876292841208, 'fraction_numerical': 0.0008111944838775097, 'mean_word_length': 4.661882893226177, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 97, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6154857', 'n_tokens_mistral': 3029, 'n_tokens_neox': 3061, 'n_words': 759}