graphql-compose / graphql-compose/graphql-compose-mongoose

How to handle custom types?

Open
#161 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
706
Forks
98
PR merge metrics
No merged PRs in 30d

Description

How should I handle models with custom types such as [`mongoose-long`]?

Currently I get the following error when creating a `TypeComposer` with `composeWithMongoose` if the model has a field using the custom type `mongoose.Schema.Types.Long`.

```
Uncaught Exception: Error: You provide incorrect mongoose field to `deriveComplexType()`. Correct field should contain `path` and `instance` properties.
at deriveComplexType (/code/node_modules/graphql-compose-mongoose/lib/fieldsConverter.js:228:11)
at convertFieldToGraphQL (/code/node_modules/graphql-compose-mongoose/lib/fieldsConverter.js:197:23)
at Object.keys.forEach.fieldName (/code/node_modules/graphql-compose-mongoose/lib/fieldsConverter.js:145:13)
at Array.forEach ()
at convertModelToGraphQL (/code/node_modules/graphql-compose-mongoose/lib/fieldsConverter.js:142:31)
at composeWithMongoose (/code/node_modules/graphql-compose-mongoose/lib/composeWithMongoose.js:30:57)
```

[`mongoose-long`]: https://www.npmjs.com/package/mongoose-long

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with fieldsConverter.js, especially deriveComplexType() and convertFieldToGraphQL(), then trace how composeWithMongoose() passes model fields into them. Reproduce the failure with a mongoose.Schema.Types.Long field and verify that custom types can be converted without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.