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

Helper methods: resolve #42

Open
mishushakov opened this issue Mar 9, 2023 · 6 comments
Open

Helper methods: resolve #42

mishushakov opened this issue Mar 9, 2023 · 6 comments

Comments

@mishushakov
Copy link
Member

mishushakov commented Mar 9, 2023

Specify resolvers directly in schema

Example:

g.type('Query', {
  test: g.string().resolve(() => 'Hello World')
})
@kasper573
Copy link

kasper573 commented Apr 11, 2023

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()}`)
})

@mishushakov
Copy link
Member Author

Great question. I will have to investigate this

@raja-OX
Copy link

raja-OX commented May 7, 2023

@mishushakov any update?

@mishushakov
Copy link
Member Author

Not yet, is this important for you? Why doesn't the existing solution suffice?

@raja-OX
Copy link

raja-OX commented May 9, 2023

@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.

@mishushakov
Copy link
Member Author

@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

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