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
A "special function" for dynamic/custom/variables/on-the-fly queries #120
Comments
Queries are never entirely dynamic it's always a finite set. I could provide a flag for you to disable the production mode entirely so all queries are always compiled. FYI compiling is very fast so it won't be an issue unless you are dealing with a very high QPS. The issue then is that anyone on the internet can then execute any query against your DB partially limited by your backend filter and column configs. However I'll never recommend allowing the public internet to control your If you use fragments your GraphQL queries can pretty easy to write and really light weight and they will also be fast and secure.
|
Why?
There is no need. Quite simply: I just need to filter on some columns of some tables.
I am.
Can you explain better these risks? I wish I could configure which columns to filter. Create the appropriate indexes only on those columns and go live in production with these settings. I would like to configure a maximum LIMIT too. Et voilà!
Taking only these two columns ( But then I would also like to filter by For this reason I am proposing you to have a "dynamic" part/function/feature of SuperGraph, maybe even not optimized on the DB (I don't care to wait, as a user I know that this could be a long query on a non-indexed DB, I wait more, I really don't care as long as I can get the data I need). From here: #114 (comment): The problem I have is to ExampleTake Github's issues page > Sort menu, what I need is very similar: I can sort results by many columns (even by reactions!). Another exampleIn this tutorial here: https://www.howtographql.com/react-urql/7-pagination-and-cache-updates/ they use this query: export const FEED_QUERY = gql`
query FeedQuery($first: Int, $skip: Int, $orderBy: LinkOrderByInput) {
feed(first: $first, skip: $skip, orderBy: $orderBy) {
count
...
}
}
` And they use const variables = React.useMemo(() => ({
skip: isNewPage ? (page - 1) * 10 : 0,
first: isNewPage ? 10 : 100,
orderBy: isNewPage ? 'createdAt_DESC' : null
}), [isNewPage, page]) Another exampleHere a user is trying to solve the same problem using sqlc:
As you can see I need to sort the results not only by one column but many. And creating so many javascript queries is wasteful and counterproductive. Which is the opposite of what SuperGraph would like to achieve: 100% productivity. 😄 |
I had never seen the Github's API: https://developer.github.com/v4/explorer/. This is exactly what I would like to do with SuperGraph: THIS IS AMAZING! |
FYI you don't have to specify the variable types in the query the types are derived from the database column information internally. Super Graph ignores this type information.
can be
I'm thinking on how to implement this correctly I agree if it helps the higher purpose "100% productivity" then we should figure out how to implement it. |
This feature aligns SuperGraph with all the products already established on the market (such as Postgraphile and Hasura). And it makes it better than the other products both because of its flexible use (both as a library and as a service) and because of Go, an extraordinary language. Thanks for your constant effort. I can't wait to try the changes and make this project shine more and more! 😄😄😄 |
@dosco, not to rush you or annoy you: is there any news on this? Or do I have to write over a hundred client-side queries for my next project? 😄 😄 😄 🥰 |
Sorry about that will look into some of these issues next week |
Closing fixed in f4354f6 |
What would you like to be added:
A "special feature" for fully custom and dynamic queries using GraphQL
variables
.Why is this needed:
A really incredible peculiarity of SuperGraph is that of creating very fast pre-compiled queries.
This clashes with the needs that emerged from issues #114 and #115: having the ability to create dynamic and custom queries.
It would be great to be able to use GraphQL's intrinsic dynamism (expressed by the
variables
in the paypload) to create queries on-the-fly (obviously not pre-compiled), (maybe) slower but certainly more useful in some applications.Example:
or
What you can today
I think one of the ways to get around this today with SuperGraph is to create many queries in clients (javascript or whatever it is) each for every need.
Example:
Sorting by different columns; by ID DESC:
Sorting by different columns; by created_ad DESC:
And so on...
As you can understand, this is really expensive.
With SuperGraph I increase the backend productivity but I decrease the frontend one.
Can you suggest something different, @dosco? Where do you think I'm wrong?
The text was updated successfully, but these errors were encountered: