Skip to content

Commit e421841

Browse files
committed
Removed unused methods in DynamicResolverBase
1 parent e254691 commit e421841

File tree

1 file changed

+2
-74
lines changed

1 file changed

+2
-74
lines changed

src/dynamic-resolver/dynamic-resolver-base.ts

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,10 @@
1-
import { GraphQLResolveInfo } from 'graphql'
2-
3-
import { getNavigationMaps, INavigationMap } from '../dynamic-navigations'
4-
import {
5-
extractGraphQLSelectionPath,
6-
extractGraphQLSelections,
7-
toCamelCase,
8-
updatePathInfoFromSchema,
9-
} from '../helpers'
10-
1+
import type { GraphQLResolveInfo } from 'graphql'
2+
import type { INavigationMap } from '../dynamic-navigations'
113
import type { Dictionary } from '../types'
124

135
export abstract class DynamicResolverBase {
146
constructor(protected readonly prisma: any) {}
157

16-
protected getSelectionObject(info: GraphQLResolveInfo, selectionMap?: Dictionary<string>) {
17-
const select = extractGraphQLSelections({
18-
node: info.fieldNodes[ 0 ],
19-
selectionMap,
20-
})
21-
22-
return select
23-
}
24-
25-
protected getSelectionPath(info: GraphQLResolveInfo, selectionMap?: Dictionary<string>) {
26-
const selectionPath = extractGraphQLSelectionPath({
27-
path: info.path,
28-
})
29-
30-
const pathInfoList = selectionPath
31-
pathInfoList.forEach(pathInfo => {
32-
if (pathInfo.table) return
33-
34-
const tableName = toCamelCase(pathInfo.tableName)
35-
const maps = getNavigationMaps()
36-
.filter(it => it.sourceTableName === tableName)
37-
38-
pathInfo.table = maps[ 0 ]?.source
39-
pathInfo.navigationMaps = maps
40-
41-
updatePathInfoFromSchema(pathInfo, info.schema)
42-
})
43-
44-
const query = pathInfoList[ 0 ]
45-
46-
if (pathInfoList.length < 3) {
47-
throw new Error(`The navigation source could not be extracted in (${query.propertyName})`)
48-
}
49-
50-
const firstLink = pathInfoList[ 1 ]
51-
52-
if (!firstLink.table) {
53-
throw new Error(`The navigation target could not be extracted in (${query.propertyName}): '${firstLink.propertyName}' → ?`)
54-
}
55-
56-
const secondLink = pathInfoList[ 2 ]
57-
58-
if (!secondLink.table) {
59-
throw new Error(`The navigation target could not be extracted in (${query.propertyName}): ${firstLink.propertyName}${secondLink.propertyName}' → ?`)
60-
}
61-
62-
const sourceTableName
63-
= selectionMap?.[ firstLink.propertyName ]
64-
?? toCamelCase(firstLink.table.name)
65-
66-
const source = this.prisma[ sourceTableName ]
67-
if (!source) {
68-
throw new Error(`Unrecognized Prisma model: "${sourceTableName}". Failed to build resolver for navigation: '${sourceTableName}${secondLink.propertyName}'`)
69-
}
70-
71-
return {
72-
to: secondLink,
73-
root: query,
74-
from: firstLink,
75-
source,
76-
selectionPath,
77-
}
78-
}
79-
808
protected resolve(parent: any, _primaryKeyName: string, _info: GraphQLResolveInfo, navigationMap: INavigationMap, _selectionMap?: Dictionary<string>) {
819
const {
8210
relation,

0 commit comments

Comments
 (0)