garph
garph copied to clipboard
Helper methods: `resolve`
Specify resolvers directly in schema
Example:
g.type('Query', {
test: g.string().resolve(() => 'Hello World')
})
Wouldn't this become a problem on the client? Since the runtime type information is required to initialize the client. Isn't it safe to say that type and resolve code fundamentally always must be separated to prevent the client from accidentally bundling server code?
Example:
import thing from "huge-server-side-library";
g.type('Query', {
test: g.string().resolve(() => `Hello World: ${thing.computeSomething()}`)
})
Great question. I will have to investigate this
@mishushakov any update?
Not yet, is this important for you? Why doesn't the existing solution suffice?
@mishushakov No problem in existing solution but I have issues with schema declarations in separate files. Have difficulties in schema declarations in separate files.
g.type('Query', {
test: g.string().resolve(() => 'Hello World')
})
If I have solution like above it will be easy for schema declarations in separate files.
@ksandin We have now shipped a babel plugin, that will compile some of the runtime information to static artefacts. Of course, we are still exploring other ways to work around that and would love to have your feedback!
https://github.com/stepci/garph-gqty#using-the-babel-plugin-alpha