Graphiti icon indicating copy to clipboard operation
Graphiti copied to clipboard

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

Open cshadek opened this issue 4 years ago • 3 comments

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 avatar Feb 20 '21 17:02 cshadek

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?

cshadek avatar Feb 20 '21 17:02 cshadek

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.

paulofaria avatar Feb 20 '21 22:02 paulofaria

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

cshadek avatar Feb 21 '21 01:02 cshadek

This has been resolved by https://github.com/GraphQLSwift/Graphiti/pull/87

NeedleInAJayStack avatar Jan 30 '23 06:01 NeedleInAJayStack