Skip to content

Commit

Permalink
Correct generic type argument order for ObjectTypeExtension sqlTable …
Browse files Browse the repository at this point in the history
…thunk

I think I screwed this up in join-monster#418. We unthunk passing the context as the second argument here like we do everywhere else: https://github.com/join-monster/join-monster/blob/73ef3473713bf88e955188ec888a8a0540cabef6/src/query-ast-to-sql-ast/index.js#L275 . Confusingly, the `ThunkWithArgsCtx` takes the type arguments in a different order than the function it represents, but I think it's not worth causing a breaking change to make these aligned.
  • Loading branch information
airhorns committed May 20, 2021
1 parent 73ef347 commit 009b1da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.d.ts
Expand Up @@ -37,7 +37,7 @@ export type ThunkWithArgsCtx<T, TContext, TArgs> =

export interface ObjectTypeExtension<TSource, TContext> {
alwaysFetch?: string
sqlTable?: ThunkWithArgsCtx<string, any, TContext>
sqlTable?: ThunkWithArgsCtx<string, TContext, any>
uniqueKey?: string | string[]
}

Expand Down
15 changes: 15 additions & 0 deletions test-d/index.test-d.ts
Expand Up @@ -20,6 +20,21 @@ const User = new GraphQLObjectType({
fields: {}
})

// test sqlTable thunk
new GraphQLObjectType<any, ExampleContext>({
name: 'User',
extensions: {
joinMonster: {
sqlTable: (args, context) => {
expectType<any>(args)
expectType<ExampleContext>(context)
return 'expr'
}
}
},
fields: {}
})

// test field extensions
new GraphQLObjectType<any, ExampleContext>({
name: 'User',
Expand Down

0 comments on commit 009b1da

Please sign in to comment.