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

Is there a way to create parts of the schema in another file or function? #51

Closed
cshadek opened this issue Feb 20, 2021 · 4 comments
Closed

Comments

@cshadek
Copy link
Contributor

cshadek commented Feb 20, 2021

Is there a way to create parts of the schema in another file or function, similar to SwiftUI?

 init(resolver: Resolver) throws {
        ...
        self.schema = try Schema<RootAPI, UserContext> {
        
               OtherSchema()
               TypeDeclaredElseWhere()

        }
}

Where OtherSchema would be another schema or group of fields from another file or function.

@cshadek
Copy link
Contributor Author

cshadek commented Feb 20, 2021

If it helps, my current use case is as follows: I have 2 schemas (one for public access and one for authenticated access). I would like to have a set of types and queries that are shared by both of these schemas. So ideally, I would declare the shared parts of the schema in one place and use them in both schemas. Is this possible?

@paulofaria
Copy link
Member

paulofaria commented Feb 20, 2021

Hello, @cshadek. I'm afraid this is not possible now. However, I think it should be easy to implement it by adding an initializer that takes a fully formed schema as a base and extends it. Maybe even a list of schemas. Are you willing to give it a try? Otherwise I can add that in the next release. Its release date is TBD, though.

@cshadek
Copy link
Contributor Author

cshadek commented Feb 21, 2021

@paulofaria, sure I can give it a try. Are you able to provide any pointers for me?

@NeedleInAJayStack
Copy link
Member

This has been resolved by #87

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

No branches or pull requests

3 participants