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

[Feature Request] Multiple entry zmodels in VS Code extension #1532

Open
platon-ivanov opened this issue Jun 24, 2024 · 6 comments
Open

[Feature Request] Multiple entry zmodels in VS Code extension #1532

platon-ivanov opened this issue Jun 24, 2024 · 6 comments
Milestone

Comments

@platon-ivanov
Copy link

platon-ivanov commented Jun 24, 2024

Is your feature request related to a problem? Please describe.
Currently using a structure with multiple entry zmodel schemas in different directories with their own User models or models with @@auth flags only respects one of the auth models in the VS Code extension.

- dbs
  - db1
    - schema.zmodel
  - db2
    - schema.zmodel
model User {
  @@allow('read', auth() == this) // works fine in `db1` directory. "incompatible operand types" when in `db2` directory.
}

Describe the solution you'd like
As @jiashengguo pointed out, a configuration setting could be introduced to support multiple schemas:

I think it's related to how the VSCode plugin works. From VSCode point of view, there is no entry schema as in CLI, so it just loads all the ZModel file could find in the project and try to compile them together. That's why you will see the error because there are two User models now.

I think in order to support multiple schema set in the same project, we probably need to introduce some configuration setting like

{
  "zmodelEntries": ["**/dbs/db1/schema.zmodel",  "**/dbs/db2/schema.zmodel"]  
} 
@jasonmacdonald
Copy link
Contributor

I just hit this as well and couldn't figure out why my schemas were now throwing errors. We use a mono repo, and I added another schema to a package we are building for a Zenstack plugin as an artifact for testing.

Thanks for finding this. It was causing me some undue stress trying to determine why I was getting this error. At least now I know why and that it's just VSCode, but it would be good to resolve this issue as, like me, others may hit this error and not realize the root cause.

@jasonmacdonald
Copy link
Contributor

@ymc9 I might look into this, as it's becoming more of a nuisance. Do you have any suggestions or preferences for correcting this before I start? I'd prefer not to go down the wrong path at the start.

@ymc9
Copy link
Member

ymc9 commented Oct 23, 2024

Hi @jasonmacdonald , thanks for offering to fix it! Since it's only for IDE we probably should configure it inside vscode settings. Let me check that part of code and share more thoughts back here soon.

@ymc9 ymc9 added this to the v2.8.0 milestone Oct 23, 2024
@ymc9
Copy link
Member

ymc9 commented Oct 26, 2024

Hey @jasonmacdonald , thanks for the wait. I checked the code and here're my thoughts:

Btw, the language server code is bundled during build, which can make debugging a big hard. I've made a draft PR here to show how you can turn off the bundling and directly use normal build output. With this you should be able to use the VSCode launch configurations to start the extension host and attach to the language server.

#1811

Please let me know if you run into any hurdle!

@jasonmacdonald
Copy link
Contributor

Hey @jasonmacdonald , thanks for the wait. I checked the code and here're my thoughts:

Btw, the language server code is bundled during build, which can make debugging a big hard. I've made a draft PR here to show how you can turn off the bundling and directly use normal build output. With this you should be able to use the VSCode launch configurations to start the extension host and attach to the language server.

#1811

Please let me know if you run into any hurdle!

This is still on my list, but I needed to switch focus last week due to unforeseen circumstances. I hope to get back to looking at this soon.

@ymc9
Copy link
Member

ymc9 commented Nov 4, 2024

Hey @jasonmacdonald , thanks for the wait. I checked the code and here're my thoughts:

Btw, the language server code is bundled during build, which can make debugging a big hard. I've made a draft PR here to show how you can turn off the bundling and directly use normal build output. With this you should be able to use the VSCode launch configurations to start the extension host and attach to the language server.
#1811
Please let me know if you run into any hurdle!

This is still on my list, but I needed to switch focus last week due to unforeseen circumstances. I hope to get back to looking at this soon.

Sure. Please take your time! I'm wrapping up v2.8 release but we can always release a patch whenever you have time to work on the PR.

@ymc9 ymc9 modified the milestones: v2.8.0, v2.8.x Nov 7, 2024
@ymc9 ymc9 modified the milestones: v2.9.0, v2.9.x Nov 22, 2024
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

No branches or pull requests

3 participants