Skip to content
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

Limit container scope to single schema #241

Merged
merged 4 commits into from Jan 27, 2019
Merged

Conversation

MichalLytek
Copy link
Owner

Right now, the only way to register a 3rd party DI container is by using the global useContainer function. But this global way force us to share the same container between multiple buildSchema calls and multiple schemas will call in runtime the same container.

This PR change this API and make the container to be passed as the buildSchema option:

import { Container } from "typedi"
import { buildSchema } from "type-graphql"

await buildSchema({
  resolvers,
  container: Container,
});

It is placed in build context like the rest of the buildSchema options.

This PR will allow to move toward #110 and multiple schemas support without any leaks between them.

@MichalLytek MichalLytek added the Enhancement 🆕 New feature or request label Jan 26, 2019
@MichalLytek MichalLytek added this to the 1.0.0 release milestone Jan 26, 2019
@MichalLytek MichalLytek self-assigned this Jan 26, 2019
@MichalLytek MichalLytek added this to In review in Board via automation Jan 26, 2019
@codecov
Copy link

codecov bot commented Jan 26, 2019

Codecov Report

Merging #241 into master will increase coverage by 0.29%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #241      +/-   ##
==========================================
+ Coverage   95.58%   95.88%   +0.29%     
==========================================
  Files          67       67              
  Lines        1064     1044      -20     
  Branches      187      183       -4     
==========================================
- Hits         1017     1001      -16     
+ Misses         46       42       -4     
  Partials        1        1
Impacted Files Coverage Δ
src/utils/index.ts 100% <ø> (ø) ⬆️
src/resolvers/create.ts 100% <100%> (ø) ⬆️
src/utils/container.ts 100% <100%> (+10.52%) ⬆️
src/resolvers/helpers.ts 100% <100%> (ø) ⬆️
src/schema/build-context.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 90d55a8...3ecbf5b. Read the comment docs.

@MichalLytek MichalLytek merged commit a3ddf6b into master Jan 27, 2019
Board automation moved this from In review to Done Jan 27, 2019
@MichalLytek MichalLytek deleted the container-build-context branch January 27, 2019 12:52
EndyKaufman pushed a commit to EndyKaufman/typegraphql-prisma-nestjs that referenced this pull request Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 🆕 New feature or request
Projects
Board
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant