Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[schema] Circular dependencies #3014

Closed
mdartic opened this issue Jan 27, 2023 · 0 comments
Closed

[schema] Circular dependencies #3014

mdartic opened this issue Jan 27, 2023 · 0 comments

Comments

@mdartic
Copy link
Contributor

mdartic commented Jan 27, 2023

Following the tip in #2993,

I'm blocked when I want to specify schemas with circular dependencies.

Example :
I have users, and workspaces.
Each user can have several workspace, but one workspace belongs to one user.

So I would like to specify my schemas like this :

// user.schema.ts
import { workspaceSchema } from "../workspace/workspace.schema"
const userSchema = Type.Object({
  // ...
  workspace: Type.Optional(Type.Ref(workspaceSchema))
}, { $id: 'User', additionalProperties: false })

// workspace.schema.ts
import { userSchema } from "../users/user.schema"

const workspaceSchema = Type.Object({
  // ...
  user: Type.OptionalType.Ref(userSchema))
}, { $id: 'Workspace', additionalProperties: false })

I find an issue on typebox talking about this sinclairzx81/typebox#106

But I can't figure out to make this work in Feathers...

Do you have any idea ?

Actually, I'm faking the result, so it's a workspace: Type.Optional(Type.Any()).

For two models, that could work, but for nested relations, this seems a nightmare :-)

@feathersjs feathersjs locked and limited conversation to collaborators Jan 27, 2023
@daffl daffl converted this issue into discussion #3018 Jan 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant