fix: add types to authentication context object & executeQuery for @types/keystonejs__keystone (#43257)

* fix: add types to authentication context for keystone v6.0

* fix: add other fields from authentication context data packet

some fields were undefined. I have added these as optional with any for now.

* fix: pass default values with the optional options for executeQuery()

This permits
```
executeQuery(
        `query {
      _allUsersMeta {
        count
      }
    }`
```

as well as 

```
executeQuery(
        `query {
      _allUsersMeta {
        count
      }
    }`,
	{
    	variables: {
         	password,
         	email,
     	},
	}
```

* fix: remove initializer from interface property

* fix: ci error

`A parameter initializer is only allowed in a function or constructor implementation.`

* fix: i am done with semicolons
This commit is contained in:
Abhijith Vijayan 2020-03-23 20:59:52 +05:30 committed by GitHub
parent 8ab0898586
commit 7afb65a981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,8 @@
// Type definitions for @keystonejs/keystone 5.2
// Type definitions for @keystonejs/keystone 6.0
// Project: https://github.com/keystonejs/keystone
// Definitions by: Kevin Brown <https://github.com/thekevinbrown>
// Timothee Clain <https://github.com/tclain>
// Abhijith Vijayan <https://github.com/abhijithvijayan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
@ -48,7 +49,21 @@ declare module '@keystonejs/keystone' {
}
interface AuthenticationContext {
authentication: { item: any }; // TODO
authentication: {
item: {
id: string;
name: string;
email: string;
isAdmin: boolean;
password: string;
};
listKey: string;
operation: string;
originalInput?: any; // TODO: types
gqlName: string;
itemId?: any; // TODO: types
itemIds?: any; // TODO: types
};
}
interface GraphQLWhereClause {
@ -217,6 +232,11 @@ declare module '@keystonejs/keystone' {
mutations?: GraphQLExtension[];
}
interface QueryExecutionSchema {
variables?: any;
context?: any;
}
class Keystone<ListNames extends string = string> {
constructor(options: KeystoneOptions);
@ -228,7 +248,7 @@ declare module '@keystonejs/keystone' {
// The return type is actually important info here. I don't believe this generic is unnecessary.
// tslint:disable-next-line:no-unnecessary-generics
executeQuery<Output = any>(query: string, config: { variables: any; context: any }): Output;
executeQuery<Output = any>(query: string, config?: QueryExecutionSchema): Output;
connect(): Promise<void>;
disconnect(): Promise<void>;