Skip to content

Commit f9c0a2e

Browse files
author
hirsch88
committed
Fix some typos and duplicated code
1 parent dc91458 commit f9c0a2e

File tree

5 files changed

+7
-28
lines changed

5 files changed

+7
-28
lines changed

src/api/queries/GetPetsQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { GraphQLFieldConfig, GraphQLList } from 'graphql';
2-
import { Query, AbstractQuery, GraphQLContext } from './../../lib/graphql';
2+
import { Query, AbstractGraphQLQuery, GraphQLContext } from './../../lib/graphql';
33
import { PetService } from '../services/PetService';
44
import { PetType } from './../types/PetType';
55
import { Logger } from '../../core/Logger';
66
import { Pet } from '../models/Pet';
77

88
@Query()
9-
export class GetPetsQuery extends AbstractQuery<GraphQLContext<any, any>, Pet[], any> implements GraphQLFieldConfig {
9+
export class GetPetsQuery extends AbstractGraphQLQuery<GraphQLContext<any, any>, Pet[], any> implements GraphQLFieldConfig {
1010
public type = new GraphQLList(PetType);
1111
public allow = [];
1212
public args = {};

src/api/queries/GetUsersQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { GraphQLFieldConfig, GraphQLList } from 'graphql';
2-
import { Query, AbstractQuery, GraphQLContext } from './../../lib/graphql';
2+
import { Query, AbstractGraphQLQuery, GraphQLContext } from './../../lib/graphql';
33
import { UserService } from '../services/UserService';
44
import { UserType } from './../types/UserType';
55
import { User } from '../models/User';
66
import { Logger } from '../../core/Logger';
77

88
@Query()
9-
export class GetUsersQuery extends AbstractQuery<GraphQLContext<any, any>, User[], any> implements GraphQLFieldConfig {
9+
export class GetUsersQuery extends AbstractGraphQLQuery<GraphQLContext<any, any>, User[], any> implements GraphQLFieldConfig {
1010
public type = new GraphQLList(UserType);
1111
public allow = [];
1212
public args = {};

src/lib/graphql/AbstractGraphQLHooks.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import { UserError } from './graphql-error-handling';
22

3-
// export interface GraphQLHooks {
4-
// before<C, A, S>(context: C, args: A, source?: S): Promise<A> | A;
5-
// after<R, C, A, S>(result: R, context: C, args: A, source?: S): Promise<R> | R;
6-
// run<S, A, C, R>(rootOrSource: S, args: A, context: C): Promise<R> | Promise<undefined> | R | undefined;
7-
// }implements GraphQLHooks
8-
93
export abstract class AbstractGraphQLHooks<TContext, TResult, TArgs> {
104

115
/**
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
import { AbstractGraphQLHooks } from './AbstractGraphQLHooks';
1+
import { AbstractGraphQLQuery } from './AbstractGraphQLQuery';
22

33

4-
export abstract class AbstractGraphQLMutation<TContext, TResult, TArgs> extends AbstractGraphQLHooks<TContext, TResult, TArgs> {
5-
6-
/**
7-
* This will be called by graphQL and they need to have it not as a
8-
* member function of this class. We use this hook to add some more logic
9-
* to it, like permission checking and before and after hooks to alter some data.
10-
*/
11-
public resolve = async <S>(root: S, args: TArgs, context: TContext): Promise<TResult> => {
12-
// We need to store the query arguments in the context so they can be accessed by subsequent resolvers
13-
(context as any).resolveArgs = args;
14-
args = await this.before(context, args);
15-
let result = await this.run<S>(root, args, context);
16-
result = await this.after(result, context, args);
17-
return (result as TResult);
18-
}
19-
4+
export abstract class AbstractGraphQLMutation<TContext, TResult, TArgs> extends AbstractGraphQLQuery<TContext, TResult, TArgs> {
205
}

src/lib/graphql/AbstractGraphQLQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AbstractGraphQLHooks } from './AbstractGraphQLHooks';
22

33

4-
export abstract class AbstractQuery<TContext, TResult, TArgs> extends AbstractGraphQLHooks<TContext, TResult, TArgs> {
4+
export abstract class AbstractGraphQLQuery<TContext, TResult, TArgs> extends AbstractGraphQLHooks<TContext, TResult, TArgs> {
55

66
/**
77
* This will be called by graphQL and they need to have it not as a

0 commit comments

Comments
 (0)