Closed dstoyanoff closed 1 year ago
@dstoyanoff can you provide a minimal example? Otherwise it's going to be close to impossible to reproduce your issue.
I will try to reproduce it in a minimal environment and post a link here, thanks.
https://github.com/dstoyanoff/inversify-inject-issue
I've created the minimal reproduction. Run with yarn dev
. I've exposed 3 different queries on the GraphQL endpoint (api/graphql
) to showcase the different options:
// uses constructor injection (doesn't work)
query test {
constructorTest
}
// uses field injection (doesn't work)
query test {
fieldTest
}
// uses the container directly (works)
query test {
containerGetTest
}
Let me know if anything else is needed
I actually found the problem. I had to instruct type-graphql about the use of the container and register my resolvers. Pushed a fix in the repo for reference
I have turned around every corner of the internet about this issue, but couldn't find any solution.
I have configured Inversify in a project and everything seems to be working fine, besides trying to use
@inject
in a constructor or in a field.When I resolve the dependencies using the container directly, it all works, which means the registration was successful, but the injection isn't.
Expected Behavior
@inject
should work or throw an errorCurrent Behavior
The
@inject
decorator doesn't work and there are no errors in the console.Context
I am using NextJS () and the flow is triggered from a GraphQL API route.
Your Environment