I was trying to replicate the solution given for this question about the same thing. I did all that was described and my implementation looks like this:
Schema:
type Factura @collection(name: "facturas") {
number: String! @unique
date: Date!
due: Date!
user: String!
agent: Agent! @relation
// More unrelated fields...
}
type query {
facturasByDateRange(before: Date, after: Date): [Factura!]!
@resolver(name: "facturas_range", paginated: true)
}
UDF:
Query(
Lambda(
["before", "after", "size", "afterCursor", "beforeCursor"],
Map(
Paginate(
Range(Match(Index("facturas_by_date")), Var("before"), Var("after"))
),
Lambda(["date", "ref"], Let({ factura: Get(Var("ref")) }, Var("factura")))
)
)
)
I created de corresponding index and populated the database with a couple of items. Note that I chose to go with the resolver pagination
parameter set to true
, in contrast to the last part to the answer I cited.
I can test the function via the Shell, and it works well... or at least returns the right data:
But, what I try the query via graphQL, it returns an empty array!
what could be happening??
Complete Schema:
#################### Accounts and centers ####################
type Account @collection(name: "accounts") {
name: String!
code: String! @unique
imputable: Boolean!
balance: Boolean!
active: Boolean!
facturas: [Factura] @relation
}
type Center @collection(name: "centros") {
code: String! @unique
name: String!
active: Boolean!
facturas: [Factura] @relation
}
#################### Documents ####################
type Detail {
# Centro y cuenta son solo strings, ya que se usan solo para representar en UI
centro: String!
cuenta: String!
desc: String!
imponible: Int!
import: Boolean!
origin: String!
q: Int!
totEx: Int!
tot5: Int!
tot10: Int!
factura: Factura! @relation
}
type Factura @collection(name: "facturas") {
number: String! @unique
date: Date!
due: Date!
printed: Boolean!
state: String!
pay: String!
user: String!
agent: Agent! @relation
client: Client! @relation
currency: String!
exchange: Int!
totEx: Int!
tot5: Int!
tot10: Int!
tot: Int!
totG: Int!
tax5: Int!
tax10: Int!
centers: [Center] @relation
accounts: [Account] @relation
details: [Detail!] @relation
}
type Numbering @collection(name: "numbering") {
suc: Int!
boca: Int!
from: Int!
to: Int!
last: Int!
type: String!
curr: String!
number: Int!
start: Date!
end: Date!
state: Boolean!
tag: String
comm: String
}
#################### Usuarios y personas ####################
type Client @collection(name: "clients") {
name: String!
ruc: String! @unique
ret: Boolean!
address: String!
city: String!
country: String!
ext: Boolean!
email: String
tel: String!
fax: String
contact: String
facturas: [Factura] @relation
}
type Agent @collection(name: "agents") {
name: String!
email: String
tel: String
ci: String @unique
facturas: [Factura] @relation
}
type Query {
# Accounts
allAccounts: [Account!]! @index(name: "all_accounts")
getAccount(code: String!): Account
activeAccounts(active: Boolean!): [Account!]! @index(name: "active_accounts")
impAccounts(active: Boolean!, imputable: Boolean!): [Account!]!
@index(name: "imp_accounts")
# Centers
allCenters: [Center!]! @index(name: "all_centers")
activeCenters(active: Boolean!): [Center!]! @index(name: "active_centers")
# Clients
allClients: [Client!]! @index(name: "all_clients")
# Numbering
allNumbering: [Numbering!]! @index(name: "all_numbering")
lastNumbering(type: String!, tag: String!, state: Boolean!): [Numbering!]!
@index(name: "last_numbering")
# Facturas
allFacturas: [Factura!]! @index(name: "all_facturas")
facturasByDateRange(before: Date, after: Date): [Factura!]!
@resolver(name: "facturas_range", paginated: true)
}