GraphQL object fulfilled by querying two different data-stores; how to do this efficiently?

Aperta
#307 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
fsharp, graphql

Direzione di ricerca

Inizia dal punto di ingresso Define.Object("Book", ...) menzionato nell’issue e leggi la documentazione o gli esempi circostanti sulla risoluzione degli oggetti e dei campi. Una soluzione è completata quando le query che usano solo campi veloci usano fetchFastFields, le query che richiedono campi lenti usano fetchSlowFields e nessuna delle due funzioni viene chiamata più di una volta per Book.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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):

  • id
  • title
  • author
  • datePublished

The other fields are "big", and they are stored in a slow data-store (e.g. Amazon S3):

  • fullText
  • blurb

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 Book in a query, do not call fetchFastFields or fetchSlowFields more than once.

How should I write my Define.Object("Book", ... code to achieve this?

Lingua principale
F#
Stelle
406
Fork
74
Merge medio
1g 8h
PR unite (30g)
14

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fsprojects/FSharp.Data.GraphQL

Tutte le issue di fsprojects/FSharp.Data.GraphQL

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.