Skip to content

Commit 5341866

Browse files
Merge pull request #15 from RoboVault/fix/schema-composer
fixing schema composer
2 parents 97a6d98 + 68ae93c commit 5341866

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v0.4.17
2+
- fix: bug in schema composer where it was not properly handling entities
3+
14
# v0.4.16
25
- feat: enhance `arkiver list` command, see `arkiver list --help`
36
- feat: added 3 new commands to the CLI:

cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from './cli/mod.ts'
1818
import 'https://deno.land/std@0.179.0/dotenv/load.ts'
1919

20-
export const version = 'v0.4.16'
20+
export const version = 'v0.4.17'
2121

2222
const command = new Command()
2323
.name('arkiver')

src/deps.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export {
2424
} from 'npm:abitype'
2525
export { default as mongoose, Schema, Types } from 'npm:mongoose'
2626
export { SchemaComposer, schemaComposer } from 'npm:graphql-compose'
27-
export { composeMongoose } from 'npm:graphql-compose-mongoose'
27+
export {
28+
composeMongoose,
29+
type ObjectTypeComposerWithMongooseResolvers,
30+
} from 'npm:graphql-compose-mongoose'
2831
export { LRUCache as Cache } from 'npm:lru-cache'
2932
export * as log from 'https://deno.land/std@0.181.0/log/mod.ts'
3033
export * as colors from 'https://deno.land/std@0.181.0/fmt/colors.ts'

src/graphql/builder.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
// deno-lint-ignore-file no-explicit-any
2-
import { composeMongoose, mongoose, SchemaComposer } from '../deps.ts'
2+
import {
3+
composeMongoose,
4+
mongoose,
5+
ObjectTypeComposerWithMongooseResolvers,
6+
SchemaComposer,
7+
} from '../deps.ts'
38

49
export const buildSchemaFromEntities = (
510
schemaComposer: SchemaComposer,
611
entities: { model: mongoose.Model<any>; list: boolean }[],
712
) => {
813
for (const { model, list } of entities) {
9-
const getTC = (schemaComposer: any, model: any) => {
14+
const getTC = (
15+
schemaComposer: SchemaComposer,
16+
model: mongoose.Model<any>,
17+
) => {
1018
try {
11-
return schemaComposer.getAnyTC(model.modelName)
19+
return schemaComposer.getOTC(
20+
model.modelName,
21+
) as ObjectTypeComposerWithMongooseResolvers<any>
1222
} catch (_e) {
13-
return composeMongoose<any>(model)
23+
return composeMongoose<any>(model, { schemaComposer })
1424
}
1525
}
1626

@@ -28,7 +38,7 @@ export const buildSchemaFromEntities = (
2838
[_id]: (source: any) => source[path],
2939
},
3040
projection: { [path]: 1 },
31-
})
41+
} as any)
3242
}
3343
}
3444

0 commit comments

Comments
 (0)