-
Notifications
You must be signed in to change notification settings - Fork 64
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
this.findOneById is not a function (Apollo Server Express v4 GraphQL) #114
Comments
dataSources in v3 were as follows:
but in the new version dataSources is inside the context |
what i did is i override my datasource class so I can call the initialize method inside in the MongoDatasource class. Now it works for me.
then in my context
|
Thanks, @systemkrash , it is working now. hopefully, they update apollo-datasource-mongodb soon :) |
i can modify the code but i don't have time to do so because of my tight deadlines. but I think this is the fix. the cache attribute of the class needs to be expose in the constructor to work on apollo-server v4 :D glad it works for you. :) |
@systemkrash Thank you for your code snippet, it's of great help!
Also I'll have a problem, even with a defined context. I was exploiting the fact that the dataSources context was containing the other dataSources and himself: // inside any of my DataSource extended class
this.context.dataSources.users.findOneById(this.context.token) EDIT: |
Sounds like it's not! In which case I think we should:
I'd welcome a PR for # 2. https://www.apollographql.com/docs/apollo-server/migration/#datasources |
I believed its not undefined because that attribute belongs to MongoDataSource class which we use to extend our own Datasource class. sorry for the late response. |
Hi @lorensr , I have been working on upgrading Apollo Server 3 to 4 in my own project where I using this package. I created a fork to update The major change was removing In this case, I defined a Also, since everything is initialized in the data source constructors and the abstract I also removed some deprecated packages like apollo-server-errors, as in v4, I created a pull request for my fork that you can review. If you have any further questions about the changes I made, feel free to message me. I also updated the README to reflect the changes and some links to relevant documentation on Apollo Server. |
This issue report is going on a year now, any hope on a resolution? |
I have the following ApolloServer (v4)
when I run graphql and send one assetId, everything is working till I get following error:
By the way (this.) has collection and model objects but not any methods.
is it because apollo-datasource-mongodb is not compatible with the new version of apollo server v4?
The text was updated successfully, but these errors were encountered: