Skip to content

feat(epic): 0.12.0 Plugin System and Internal Refactor #242

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

Merged
merged 54 commits into from
Nov 7, 2019

Conversation

tgriesser
Copy link
Member

@tgriesser tgriesser commented Oct 3, 2019

Summary of all changes in 0.12.0:

  • Adds comprehensive "Plugins" API, see the docs for more info on what all these can help accomplish
  • deletes previous types file before writing next (fix(typegen): delete prev file before writing next #252)
    • This helps VSCode pick up its changed version when types are updated
  • Adds shouldExitAfterGenerateArtifacts to makeSchema config
    • Makes it possible to exit after the types are generated, useful if you do not check a schema artifact into source control, but wish to generate before the code runs.

Plugins:

  • Add nullabilityGuardPlugin, to help provide fallback values when null is returned in a non-null field position. See the docs for more info.
  • Add fieldAuthorizePlugin. See the docs for more info
    • This is the same behavior as the (currently undocumented) behavior of having authorize on the field, but implemented more flexibly as a plugin. This will be automatically added if no plugins are specified, otherwise it will need to be imported & added to makeSchema alongside other plugins.

Breaking:

  • Bumps the default minimum peer-dependency version of graphql-js to 14.5.0
    • Nexus uses the new extensions property on types to store metadata provided to Nexus types, in order to make them usable by plugins.
  • Moves field level authorization to a Nexus plugin. This will automatically be enabled in the same way as the current behavior, so as to prevent breaking changes.
  • Removes nexusWrappedType
    • This was an internal implementation detail which should not affect end users
  • Removes t.modifyType API
    • This may not have ever worked, it was only intended to modify fields on an objectType which were originally implemented by an interface. Please open an issue if this is a breaking change for you, so we can understand the use-case and design a better API.

Additional

  • Improves code coverage, adds base threshold to new PRs
  • Warn on missing outputs in makeSchema config

@jasonkuhrt jasonkuhrt mentioned this pull request Oct 3, 2019
5 tasks
@jasonkuhrt
Copy link
Contributor

Relates to #98

Copy link
Contributor

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

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

Great work, I understand but some subset of it :) Hope the feedback is useful!

@jasonkuhrt jasonkuhrt mentioned this pull request Oct 3, 2019
2 tasks
* develop:
  chore: correct code comment
  feat: by default typegen as an @types package (#230)
  chore: simplify tsconfig (#240)
  docs(prisma2): fix some api and link error (#231)
  chore: dev script for lib work (#235)
  core: replace circleci badge link (#233)
  chore: apply prettier to test code
  chore: improve assertion error message
  refactor: simplify integration test (#228)
  Remove file:. from devDependencies (#227)
* develop:
  v0.12.0-beta.13
  Update README.md
  fix(typegen): explicitly await removeFile before write (#254)
  v0.12.0-beta.12
  fix(typegen): correct default typegen @types path!
  v0.12.0-beta.11
  chore: fix tests
  fix(typegen): correct default typegen @types path
  v0.12.0-beta.10
  feat(config): env var for should-generate-artifacts (#244)
  docs: remove spectrum link (#250)
  feat(typegen): nicer generated package name (#248)
  fix(typegen): delete prev file before writing next (#252)
  refactor: clean up config processing & tests (#246)
  fix(config): correct default output paths
* develop:
  chore: add codecov (#258)
  feat(deps): add support for TypeScript 3.6 (#255)
@Weakky Weakky mentioned this pull request Oct 14, 2019
@beeplin
Copy link

beeplin commented Oct 17, 2019

I noticed that nexus-prisma 0.5.0 is out as a nexus plugin. Does that mean this plugin system is ready to use now for, say, auth usage, too?

@jasonkuhrt
Copy link
Contributor

jasonkuhrt commented Oct 18, 2019

Hey @beeplin, only the typedef aspect is pluggable right now. And it is very early. But yes available in the latest beta. The available part does not have middleware yet, so does not help with auth. The nexus plugin features in beta now came from #236 which is a conceptual subset of this PR.

@tgriesser tgriesser changed the title WIP: Plugin system Epic: 0.12.0 Plugin System and Internal Refactor Nov 4, 2019
@tgriesser tgriesser changed the title Epic: 0.12.0 Plugin System and Internal Refactor feat(epic): 0.12.0 Plugin System and Internal Refactor Nov 5, 2019
@tgriesser tgriesser marked this pull request as ready for review November 5, 2019 00:17
* develop:
  chore(deps): bump knex from 0.16.3 to 0.19.5 in /examples/ghost (#301)
  chore(deps): bump mixin-deep from 1.3.1 to 1.3.2 in /examples/star-wars (#300)
  chore(deps): bump mixin-deep in /examples/kitchen-sink (#299)
@tgriesser tgriesser merged commit 50bf298 into develop Nov 7, 2019
@tgriesser tgriesser deleted the plugin-system2 branch November 7, 2019 21:39
@larsivi
Copy link

larsivi commented Jan 6, 2020

I want to use the plugin system in conjunction with prisma 1 and nexus-prisma (the old one), since Prisma 2 and friends are currently not an option. nexus-prisma 0.3.8 does use nexusWrappedType however (see graphql-nexus/nexus-plugin-prisma#520).

Is there some easy way to migrate nexusWrappedType to a public API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants