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

[legacy-framework] Console - Load Nested Mutations and Queries #3031

Merged
merged 3 commits into from
Dec 8, 2021

Conversation

skotchpine
Copy link

The Problem

When I run blitz c, my queries and mutations aren't loaded. This is because in next-console.ts mutations and queries are only loaded if they are directly inside a mutations or queries directory. I nest mine one directory further. I'll explain why, but feel free to skip to the features at the bottom.

Rationale

I like conventions. I'm structuring my project like this:

/app/api/feature/example.js
/app/components/feature/Example.js
/app/integrations/feature/featureExample.js
/app/mutations/feature/exampleMutation.js
/app/pages/feature/example.js
/app/queries/feature/exampleQuery.js
/app/schemas/feature/exampleSchema.js
/app/utils/example.js
/app/db.js

There are a few reasons why this is better:

  1. The file structure of pages matches that of other type classes
  2. All type classes are visible from inside /app
  3. Other monoliths are structured this way
  4. (filenames) Using type class in filenames makes autocomplete easier
  5. (schemas) Exporting one schema per file makes adding and removing imports less work
  6. (integrations & db) Using "./app" as "baseUrl" makes imports shorter import exampleQuery from 'queries/feature/exampleQuery.js'

Feature Checklist

  • In auth example: add "console" script & currentUserQuery for dev-testing
  • Modify glob in next-console.ts to load nested queries & mutations

@skotchpine
Copy link
Author

This category of problem would be solved by loading or generating those globs from blitz.config

Copy link
Contributor

@beerose beerose left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the PR

@beerose beerose merged commit 9cff223 into blitz-js:canary Dec 8, 2021
@blitzjs-bot
Copy link
Contributor

Added @skotchpine contributions for code

@itsdillon itsdillon changed the title Console - Load Nested Mutations and Queries [legacy-framework] Console - Load Nested Mutations and Queries Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants