FSharp.Data.GraphQL
FSharp.Data.GraphQL copied to clipboard
GraphQL object fulfilled by querying two different data-stores; how to do this efficiently?
This is a question rather than an issue (although it could be turned into an issue if no good solution is found!)
Suppose I have a library of books:
type Book = {
id : ID!
title : String!
author : String!
datePublished : String!
fullText : String!
blurb : String!
}
Some of these fields are "small", and they are stored in a fast data-store (e.g. MySQL, Postgres):
idtitleauthordatePublished
The other fields are "big", and they are stored in a slow data-store (e.g. Amazon S3):
fullTextblurb
I have two functions for fetching the fields:
fetchFastFields : ID -> BookPropertiesFast
fetchSlowFields : ID -> BookPropertiesSlow
The behaviour I want on the back-end is:
- If the query can be fulfilled with only "fast" fields, call
fetchFastFields - If the query has one or more "slow" fields, call
fetchSlowFields - For each
Bookin a query, do not callfetchFastFieldsorfetchSlowFieldsmore than once.
How should I write my Define.Object("Book", ... code to achieve this?