Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sgarner committed Aug 20, 2020
1 parent d961c41 commit 38fb4ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
11 changes: 2 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ module.exports = {
parserOptions: {
parser: '@typescript-eslint/parser',
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier',
],
plugins: [
'@typescript-eslint',
'prettier',
],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'prettier'],
// add your custom rules here
rules: {
semi: ['error', 'always'],
Expand Down
11 changes: 6 additions & 5 deletions src/RelationMapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Connection, EntityMetadata, EntitySchema } from 'typeorm';
import { RelationMetadata } from 'typeorm/metadata/RelationMetadata';
import { FragmentDefinitionNode, GraphQLResolveInfo, SelectionNode, SelectionSetNode } from 'graphql';
import { ObjectType } from 'typeorm/index';

export class RelationMapper {
public constructor(private readonly connection: Connection) {}
Expand All @@ -10,7 +11,7 @@ export class RelationMapper {
* query resolver.
*/
public buildRelationListForQuery(
entity: Function | EntitySchema<any> | string,
entity: ObjectType<any> | EntitySchema<any> | string,
info: GraphQLResolveInfo,
): Set<string> {
const baseNode = info.fieldNodes.find(fieldNode => fieldNode.name.value === info.fieldName);
Expand All @@ -26,7 +27,7 @@ export class RelationMapper {
* Build the list of matching TypeORM relation property names for an entity, starting at a base SelectionNode.
*/
public buildRelationList(
entity: Function | EntitySchema<any> | string,
entity: ObjectType<any> | EntitySchema<any> | string,
baseNode: SelectionNode,
fragments?: { [p: string]: FragmentDefinitionNode },
basePropertyPath?: string,
Expand Down Expand Up @@ -113,17 +114,17 @@ export class RelationMapper {
return fieldPathNodes.find(node => node === null) === undefined;
}

private getEntityMetadata(entity: Function | EntitySchema<any> | string): EntityMetadata {
private getEntityMetadata(entity: ObjectType<any> | EntitySchema<any> | string): EntityMetadata {
return this.connection.getMetadata(entity);
}

private getRelationsMetadata(entity: Function | EntitySchema<any> | string): RelationMetadata[] {
private getRelationsMetadata(entity: ObjectType<any> | EntitySchema<any> | string): RelationMetadata[] {
return this.getEntityMetadata(entity).relations;
}

private findRelationMetadata(
nodeName: string,
entity: Function | EntitySchema<any> | string,
entity: ObjectType<any> | EntitySchema<any> | string,
): RelationMetadata | undefined {
// find relation metadata, if field corresponds to a relation property
return this.getRelationsMetadata(entity).find(relationMetadata => relationMetadata.propertyName === nodeName);
Expand Down
9 changes: 7 additions & 2 deletions test/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export const typeDefs = `

export const resolvers: IResolvers<any, TestResolverContext> = {
Query: {
products(source: any, args: any, context: TestResolverContext, info: GraphQLResolveInfo): Promise<Product[]> {
products(
source: unknown,
args: unknown,
context: TestResolverContext,
info: GraphQLResolveInfo,
): Promise<Product[]> {
context.resolveInfoHook(info);

const connection = getConnection();
Expand All @@ -92,7 +97,7 @@ export const resolvers: IResolvers<any, TestResolverContext> = {
Product: {
async media(
source: Product,
args: any,
args: unknown,
context: TestResolverContext,
info: GraphQLResolveInfo,
): Promise<(Image | Video)[]> {
Expand Down

0 comments on commit 38fb4ce

Please sign in to comment.