Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS: sync up TS typings with Flow typings #370

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions src/connection/connection.d.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,35 @@
import type {
GraphQLNonNull,
GraphQLNamedOutputType,
GraphQLScalarType,
GraphQLObjectType,
GraphQLNamedOutputType,
GraphQLFieldConfigArgumentMap,
GraphQLFieldConfigMap,
GraphQLFieldResolver,
Thunk,
} from 'graphql';

interface ForwardConnectionArgs {
after: { type: GraphQLScalarType };
first: { type: GraphQLScalarType };
}

/**
* Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field
* whose return type is a connection type with forward pagination.
*/
export const forwardConnectionArgs: GraphQLFieldConfigArgumentMap &
ForwardConnectionArgs;

interface BackwardConnectionArgs {
before: { type: GraphQLScalarType };
last: { type: GraphQLScalarType };
}
export declare const forwardConnectionArgs: GraphQLFieldConfigArgumentMap;

/**
* Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field
* whose return type is a connection type with backward pagination.
*/
export const backwardConnectionArgs: GraphQLFieldConfigArgumentMap &
BackwardConnectionArgs;
export declare const backwardConnectionArgs: GraphQLFieldConfigArgumentMap;

/**
* Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field
* whose return type is a connection type with bidirectional pagination.
*/
export const connectionArgs: GraphQLFieldConfigArgumentMap &
ForwardConnectionArgs &
BackwardConnectionArgs;
export declare const connectionArgs: GraphQLFieldConfigArgumentMap;

/**
* A type alias for cursors in this implementation.
*/
export type ConnectionCursor = string;
export declare type ConnectionCursor = string;

/**
* A type describing the arguments a connection field receives in GraphQL.
Expand Down
8 changes: 6 additions & 2 deletions src/mutation/mutation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import type {
Thunk,
} from 'graphql';

type MutationFn = (object: any, ctx: any, info: GraphQLResolveInfo) => unknown;
declare type MutationFn = (
object: any,
ctx: any,
info: GraphQLResolveInfo,
) => unknown;

/**
* A description of a mutation consumable by mutationWithClientMutationId
Expand Down Expand Up @@ -39,4 +43,4 @@ interface MutationConfig {
*/
export declare function mutationWithClientMutationId(
config: MutationConfig,
): GraphQLFieldConfig<any, any>;
): GraphQLFieldConfig<unknown, unknown>;
6 changes: 3 additions & 3 deletions src/node/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {

interface GraphQLNodeDefinitions<TContext> {
nodeInterface: GraphQLInterfaceType;
nodeField: GraphQLFieldConfig<any, TContext>;
nodesField: GraphQLFieldConfig<any, TContext>;
nodeField: GraphQLFieldConfig<unknown, TContext>;
nodesField: GraphQLFieldConfig<unknown, TContext>;
}

/**
Expand Down Expand Up @@ -39,7 +39,7 @@ interface ResolvedGlobalId {
* Takes a type name and an ID specific to that type name, and returns a
* "global ID" that is unique among all types.
*/
export declare function toGlobalId(type: string | number, id: string): string;
export declare function toGlobalId(type: string, id: string | number): string;

/**
* Takes the "global ID" created by toGlobalID, and returns the type name and ID
Expand Down
2 changes: 1 addition & 1 deletion src/node/plural.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ interface PluralIdentifyingRootFieldConfig {

export declare function pluralIdentifyingRootField(
config: PluralIdentifyingRootFieldConfig,
): GraphQLFieldConfig<any, any>;
): GraphQLFieldConfig<unknown, unknown>;