You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running Ariadne against a CosmosDB Back-End. We currently retrieve the fields from the GraphQLResolverInfo object to write specific queries to avoid running a SELECT * FROM against the backend. One issue we encounter is as follows:
In a schema and its underlying object, we have a nested array. In order to specify the fields requested in there for CosmosDB, we need to write nested joins, for example given I want account_id and the transaction_number of each transaction (= array) in a document:
Should translate to the following CosmosDB query: SELECT c.account_id, ARRAY(SELECT f.transaction_number FROM f IN c.transaction) as 'transaction FROM c WHERE c.account_id = 1234
After a hard struggle, we decided its easier to let GraphQL handle these cases and just request the complete transaction array from the DB. So given the request above: SELECT c.account_id, c.transaction FROM c WHERE c.account_id = 1234
Would still give the enduser the same result.
Our current solution is to write a function that traverses into the types of the info object, and in this case, if it encounters a GraphQLList stop iterating and return that field (e.g. transaction), but this led us down a rabbit hole and seems overly complex.
I was wondering if anyone knows a proper way to retrieve the queried fields + corresponding types, to generate a proper SQL query? Or am a complete nut job for even doing this and is there a better practice?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey,
I'm running Ariadne against a CosmosDB Back-End. We currently retrieve the fields from the GraphQLResolverInfo object to write specific queries to avoid running a
SELECT * FROM
against the backend. One issue we encounter is as follows:In a schema and its underlying object, we have a nested array. In order to specify the fields requested in there for CosmosDB, we need to write nested joins, for example given I want account_id and the transaction_number of each transaction (= array) in a document:
Should translate to the following CosmosDB query:
SELECT c.account_id, ARRAY(SELECT f.transaction_number FROM f IN c.transaction) as 'transaction FROM c WHERE c.account_id = 1234
After a hard struggle, we decided its easier to let GraphQL handle these cases and just request the complete transaction array from the DB. So given the request above:
SELECT c.account_id, c.transaction FROM c WHERE c.account_id = 1234
Would still give the enduser the same result.
Our current solution is to write a function that traverses into the types of the info object, and in this case, if it encounters a
GraphQLList
stop iterating and return that field (e.g.transaction
), but this led us down a rabbit hole and seems overly complex.I was wondering if anyone knows a proper way to retrieve the queried fields + corresponding types, to generate a proper SQL query? Or am a complete nut job for even doing this and is there a better practice?
Beta Was this translation helpful? Give feedback.
All reactions