How does one actually query db data in KS5?
See original GitHub issueThis is probably a dumb question, but… what’s the API for actually executing a query in KS5? In KS4 there was keystone.list("foo").model.find
(mongoose queries). I can’t figure out what functions actually accepts the new GraphQL strings 😬 The TODO demo in this repo doesn’t enlighten me either… and the GraphQL API page in the docs is blank… Do you use keystone.executeQuery
?
I can’t figure out the whole business with Apollo either. Is that only necessary with the Next integration, but not static?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (6 by maintainers)
Top Results From Across the Web
What is a database query? - TechTarget
A database query is either an action query or a select query. A select query is one that retrieves data from a database....
Read more >Best practices when working with Power Query - Microsoft Learn
By default, Power Query offers an automatic data type detection for unstructured data sources. You can read more about this feature and how ......
Read more >mysql - What is faster, one big query or many small queries?
So the question is, what is faster going from a server side (php, java, asp, ruby, python...) to the database and running one...
Read more >Query optimization techniques in SQL Server: the basics
In this blog pos we will talk about the basics of Query optimization techniques in SQL Server, and list some of them to...
Read more >Hierarchical Data in SQL: The Ultimate Guide - Database Star
This will result in a list of all employees with their level from the top level, or root node. The actual query looks...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a great question! One we need to do a better job of answering in the docs.
keystone.executeQuery
is what you’ll use 99% of the time - it accepts a GraphQL query string and does all the heavy lifting for you in terms of optimising queries for the particular database adapter in use and resolving relationships, etc. I highly recommend trying this method first. Except when;query
action which is passed to hooks in the last argument. This is the same askeystone.executeQuery
except it executes the query as the currently authenticated user (if your provide theskipAccessControl: true
option to the second argument ofquery
, it will behave identically tokeystone.executeQuery
.keystone.executeQuery
wherever possible), but the escape hatch for now is thekeystone.adapters
object which you can play around with to do raw mongoose or SQL queries.Apollo comes in two halves;
app-graphql
server. The fact that it’s Apollo should be treated as an implementation detail.In fact, the simplest was to query a GraphQL API is by sending a string in the body of a
fetch()
. The next simplest way is using thegraphql-request
npm library which has no caching or any other smarts. Then you get up into the kind-of smart query builders such asurql
anddraqula
, and finally into the really complex caching mechanisms as used byapollo
&relay
.BTW if you are after a SPA - the StaticApp is probably what you want. https://v5.keystonejs.com/keystone-alpha/app-static/ Set the fallback route to your SPA index file and all routes will be redirected there.