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

feat: require all files that import nexus #833

Merged
merged 9 commits into from
May 18, 2020
Merged

Conversation

Weakky
Copy link
Collaborator

@Weakky Weakky commented May 9, 2020

closes #823

  • feat: removes the graphql.ts and graphql/ convention for schema modules. Instead, nexus parses all the files resolved by typescript (based on the tsconfig.json) and looks for imports to nexus. If nexus is imported, that file will be both required in dev and in the final build production.
  • fix: properly updates the dev start module when there are layout changes so that new/deleted files get/don't get imported

Status: Waiting for discussion/approval before updating docs

TODO

  • docs
  • tests

@jasonkuhrt jasonkuhrt self-requested a review May 11, 2020 13:06
Copy link
Member

@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.

Let's make sure to do a pass on the schema guide (if needed) and the "project layout" docs section. Also maybe the @nexus/schema migration guide. Other than that, I don't think any other sections need revising. 🤔

@@ -89,36 +98,16 @@ export class Dev implements Command {
}

runDebouncedReflection(layout)

return {
entrypointScript: getTranspiledStartModule(layout, reflectionMode),
Copy link
Member

Choose a reason for hiding this comment

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

So now before every restart the hook allows altering what entrypoint source is? Cool

Copy link
Collaborator Author

@Weakky Weakky May 18, 2020

Choose a reason for hiding this comment

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

Yeah. Makes me think it's dangerous to expose that on the plugin interface. Here, what this specifically enables is the ability to refresh the required schema modules in the start module whenever a file changes.

This used to not be required because we were looking for schema modules based on the filenames. So recomputing the layout whenever a file was added/deleted was enough.

But now that we find schema modules based on their import to Nexus, we need to recompute that on every file change. Here's a simple use-case where this is needed:

  1. You create a file (that file is still not considered a nexus module)
  2. You add import { schema } from 'nexus'
  3. The start module needs to be updated to contain a require to that file
  4. You comment out the import to nexus from that file
  5. The start module needs to be updated to no longer contain a require to that file

See, nexus modules are no longer tied to file creation/deletion anymore, but entirely based on their content

@jasonkuhrt jasonkuhrt mentioned this pull request May 13, 2020
@jasonkuhrt
Copy link
Member

@Weakky once you wrap with #866 let's loop back asap to this one and get it over the finish line. IIRC its just some doc and tests.

@Weakky Weakky force-pushed the feat/better-modules-import branch from a7f87a6 to 4d9ee53 Compare May 18, 2020 12:35
@Weakky Weakky changed the title feat: require all files that imports nexus feat: require all files that import nexus May 18, 2020
@Weakky Weakky merged commit 0698db4 into master May 18, 2020
@Weakky Weakky deleted the feat/better-modules-import branch May 18, 2020 13:28
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.

middleware not running in production
2 participants