Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create index.d.ts for Typescript #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yoonhoGo wants to merge 3 commits into GraphQLGuide:master from yoonhoGo:patch-1

Conversation

@yoonhoGo
Copy link

@yoonhoGo yoonhoGo commented Dec 24, 2019

No description provided.

Copy link
Member

lorensr commented Dec 26, 2019

Thanks! Wondering how to test this (eg w/ VSCode) and publish to npm?


interface Options { ttl: number }

export abstract class MongoDataSource<T extends mongoose.Document, TContext = any> extends DataSource {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export abstract class MongoDataSource<T extends mongoose.Document, TContext = any> extends DataSource {
export abstract class MongoDataSource<T extends mongoose.Document, TContext = any> extends DataSource<TContext> {

DataSource is also a generic type, which optionally takes in the context type, which is what we should do imo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think the collection type makes these typings compatible with the native mongodb connector, which has a generic type for collection

Copy link
Collaborator

9at8 commented Dec 28, 2019
edited
Loading

@lorensr this explains in depth what to do.

TLDR; Add a "types": "index.d.ts" to package.json before publishing

constructor(collection: mongoose.Collection | mongoose.Model<T>)
public initialize(config: DataSourceConfig<TContext>): void
protected findOneById(id: string, { ttl }?: Options): T | null
protected findManyByIds(ids: string[], { ttl }?: Options): (T| null)[]
Copy link
Collaborator

@9at8 9at8 Dec 28, 2019
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ids are supposed to be ObjectIds, at least for the native driver. Can you confirm @lorensr ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. And if it comes in as a string argument, I use this function to convert:

image

Copy link

Hi guys,

Any progress on this feature..? We'd love to use this in one of our projects and for that we need the Typescript support.

Thanks in advance.
Gayan

Copy link
Member

lorensr commented Mar 25, 2020

@gayansanjeewa we're waiting on either @yoonhoGo to make the suggested changes and someone to test it, or for someone to create another PR with the changes

Copy link
Member

lorensr commented Mar 25, 2020

Merged #13, released in 0.2.4

gayansanjeewa reacted with rocket emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lorensr lorensr lorensr left review comments

@9at8 9at8 9at8 left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /