-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Expose SQL Queries in GraphQL too #16008
Comments
I've introduced this Orm framework into my framework, mainly for implementing full table indexing, but this feature should be available for reference DynamicFilterInfo dyfilter = JsonConvert.DeserializeObject<DynamicFilterInfo>(@"
{
""Logic"": ""And"",
""Filters"":
[
{ ""Field"": ""id"", ""Operator"": ""Equals"", ""Value"": 1 },
{
""Logic"": ""Or"",
""Filters"":
[
{ ""Field"": ""id"", ""Operator"": ""Equals"", ""Value"": 2 },
{ ""Field"": ""id"", ""Operator"": ""Equals"", ""Value"": 3 }
]
}
]
}");
fsql.Select<Region>().WhereDynamicFilter(dyfilter).ToList();
//WHERE id = 1 AND (id = 2 OR id = 3) https://freesql.net/guide/dynamic.html#%E5%8A%A8%E6%80%81%E6%9D%A1%E4%BB%B6 |
Thanks for sharing! So you're doing kind of embedded queries in GraphQL? |
I don't quite understand your reference to "embedded queries", I used a ContentHandler to create the full table indexes. The following code hasn't been updated in a while, in the new version I only indexed the latest version and removed the unreleased version, then inserted the data using the dictionary method The following code uses reflection, which is very low performance Then use FreeSql's own Api to implement the dynamic filtering. The following is an implementation of PagedContentItemsQuery. It also doesn't require a lot of code since it only needs to query a single table. To achieve the same effect in OC, you may have to generate some complex query statements |
What I mean is that with Any reason you opted for this instead of extending GraphQL directly? |
Because Yessql's dynamic indexes are too cumbersome, first of all, the business system I'm working on, it needs to communicate with external databases frequently, such as cross-database correlation queries If I use Yessql, I may need to correlate each field with a table. |
OK, so you use a different ORM than YesSql to access the YesSql tables, have a UI query builder to generate queries for it, and you allow GraphQL queries to include expressions for these queries. Do I understand correctly? |
Yes, exactly. |
OK, thanks! |
Oh no, it's not a direct access to Yessql's index table, I use another ORM to map some tables to the required types, add the necessary fields to the tables, and these table definitions can be generated automatically following the type definitions. The Graphql query just queries my dynamically created type data mapping table , and then associates the ContentItemIndex to return the document. |
Ah OK. |
A very interesting solution that can enhance the value in the business field! I shall continue to track the progress of your work. |
It's actually documented and works as described. You just need to check "Return Documents" on your SQL query as well. But it is unfortunate, that the unsupported queries are exposed in the GraphQL schema, as they will always fail if they do not return documents. |
Ah, I see. |
Is your feature request related to a problem? Please describe.
Related: #15959. Lucene and Elasticsearch Queries are accessible from GraphQL, see here. This makes it possible to expose arbitrary content lists in GraphQL. However, the same feature is not available for SQL Queries.
Describe the solution you'd like
Have the same kind of GraphQL integration for SQL Queries that we have for the other two.
Describe alternatives you've considered
Alternatively, we could somehow expose field querying with Content Fields Indexing (SQL) in GraphQL, also see #15959 (comment) and #7047, #12781 about this.
The text was updated successfully, but these errors were encountered: