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

How do you create a model that doesn't have hardcoded values? #1469

Open
kingsleyh opened this issue Jan 30, 2024 · 1 comment
Open

How do you create a model that doesn't have hardcoded values? #1469

kingsleyh opened this issue Jan 30, 2024 · 1 comment
Labels
question Further information is requested

Comments

@kingsleyh
Copy link

Hi,

I would like to fetch data to populate my GraphQL API from a database. All the examples I found so far were either hardcoded or extremely difficult to understand.

I believe that one of the selling points of GraphQL is that you only fetch the data you ask for in queries - so this would suggest that there should be some way of fetching data from a database for only the fields requested - so if I ask for just 2 fields in an object the query only needs to fetch those 2 fields.

I'm not sure if that is possible with this library - I'm finding it very difficult to use and I don't understand the docs much - I've built a graphQL library in Ruby before but this is the first time attempting in rust and this library works completely differently to the Ruby one.

I've also looked at Juniper - but it seems this library was forked from Juniper so has all the same understandability and usage issues I'm struggling with here.

If anyone has managed to create a GraphQL API based on data in a database using this library - please let me know how you did it and point me to any examples (preferably easy to understand ones for a rust beginner)

@kingsleyh kingsleyh added the question Further information is requested label Jan 30, 2024
@xamgore
Copy link
Contributor

xamgore commented Feb 23, 2024

Check out the Seaography project with its source code. They build a dynamic GraphQL schema based on SQL schema definitions, and proxy incoming requests to the database.

Speaking about optimizations, async-graphql provides utilities to retrieve requested set of fields. Having them, you may call .select_only() and .select_columns() methods of SeaORM, which will pass them to the underlying database driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants