Good afternoon Fauna forum, I have been struggling with something for a while and cannot seem to find an answer for. I am planning to use a function as a resolver for a graphql schema that Im working on. The function essentially is trying to find the vehicles that match the nullable filters or make, model and VIN. I may pass 1, 2 or 3 filters. In order to make the intersection work as desired, if one filter is not passed I am passing all of the vehicles. The function is below
Query(
Lambda(
["make", "model", "vin", "size", "after", "before"],
Let(
{
set: Intersection(
If(
IsString(Var("make")),
Match(Index("dealershipVehiclesByMake"), Var("make")),
Match(Index("allVehicles"))
),
If(
IsString(Var("model")),
Match(Index("dealershipVehiclesByModel"), Var("model")),
Match(Index("allVehicles"))
),
If(
IsString(Var("vin")),
Match(Index("dealershipVehiclesByVin"), Var("vin")),
Match(Index("allVehicles"))
)
),
page: If(
IsNull(Var("before")),
Paginate(Var("set"), { after: Var("after"), size: Var("size") }),
Paginate(Var("set"), { before: Var("before"), size: Var("size") })
)
},
Map(Var("page"), Lambda("ref", Get(Var("ref"))))
)
)
)
All indexes above are returning refs
The imported schema that I’m using is
vehiclesBySearchCriteria(make: String, model: String, vin: String): [DealershipVehicle!] @resolver(paginated: true)
And the type for DealershipVehicle is
type DealershipVehicle {
dealershipId: ID
dealership: Dealership
dealerId: String!
vin: String!
year: String!
make: String!
model: String!
trim: String
stock: String
price: String!
mileage: String!
exteriorColor: String
interiorColor: String
imageUrls: [String!]
trans: String
comments: String
valueAddedOptions: String
condition: String
engine: String
drive: String
mpgCity: String
mpgHighway: String
metrics: DealershipMetrics
active: Boolean
display: Boolean
}
The problem that I’m having is that we I call the function size is not actually working as expected.
There are 3 vehicles that match the criteria
Call(Function("vehiclesBySearchCriteria"), [
"Ford",
"Expedition",
null,
1,
null,
null
])
{
data: []
}
>> Time elapsed: 72ms
Here the size is some big number and it returns the correct number of records
Call(Function("searchByCriteria2"), [
"Ford",
"Expedition",
null,
244,
null,
null
])
{
data: [
{
ref: Ref(Collection("DealershipVehicle"), "280723362231091716"),
ts: 1603977510570000,
data: {
dealership: Ref(Collection("Dealership"), "280239021826769414"),
dealerId: "dallasautomarket",
vin: "1FMFK16568LA54194",
year: "2008",
make: "Ford",
model: "Expedition",
trim: "EL XLT 4WD",
stock: "9568",
price: "6500",
mileage: "189000",
exteriorColor: "",
interiorColor: "",
imageUrls: [
"http://dtimages.blob.core.windows.net/imagecache/1535/105d7572e6963148c54b46510094ae1cbcdf96dd.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/d38f9208ec23fdb2202ba51075c6e1a2801c1858.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/e880a2b0b7ec2d4f90640ca1e664998aff69548e.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/80ebfbb20b0a6df5d45ee24fa9edf3af16ecdc58.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/ef0de0d7093f04002b42a303d7cb5cfa07814635.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/5655f27a081729655305bb7d325d5471deee8754.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/40faf04b9d5eb3f3dcdffe1422d656ef7bc9740c.jpg"
],
trans: "6-Speed Automatic",
comments: "",
valueAddedOptions:
"V8, 5.4 Liter,Automatic, 6-Spd w/Overdrive,4WD,Traction Control,Stability Control,ABS (4-Wheel),Keyless Entry,Air Conditioning,Air Conditioning, Rear,Power Windows,Power Door Locks,Cruise Control,Power Steering,Tilt Wheel,AM/FM Stereo,CD/MP3 (Single Disc),Sirius Satellite,Dual Air Bags,Side Air Bags,Head Curtain Air Bags,Power Seat,Third Row Seat,Fog Lights,Running Boards,Roof Rack,Towing Pkg,Alloy Wheels",
condition: "",
engine: "5.4L V8 SOHC 16V",
drive: "4WD",
mpgCity: "",
mpgHighway: "",
active: true,
display: true
}
},
{
ref: Ref(Collection("DealershipVehicle"), "281633790864916992"),
ts: 1604845763025000,
data: {
dealership: Ref(Collection("Dealership"), "280239021826769414"),
dealerId: "dallasautomarket",
vin: "1FMFU19578LA55814",
year: "2008",
make: "Ford",
model: "Expedition",
trim: "Limited 2WD",
stock: "7154441",
price: "6800",
mileage: "168872",
exteriorColor: "",
interiorColor: "",
imageUrls: [
"http://dtimages.blob.core.windows.net/imagecache/1535/1688a385f946aa4b7be6ed99f2f7a8b3839bba22.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/47df51f85f54bbebc3e31eab37d1833e062e7786.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/60f16453cbd2db27e70ebe41b06743d30b62f320.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/8a885201be96a08a58ba6a3f44aeb5a70f95b2ce.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/1f0f80dcefe2bc30f9aa82bfc92a32f939ee8792.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/080abdcd03f491ec7695b35964a7638870b4195c.jpg",
"http://dtimages.blob.core.windows.net/imagecache/1535/52965f341c9f943a7cdbfd4fc5182861a36746ac.jpg"
],
trans: "6-Speed Automatic",
comments: "",
valueAddedOptions:
"V8, 5.4 Liter,Automatic, 6-Spd w/Overdrive,2WD,Traction Control,Stability Control,ABS (4-Wheel),Keyless Entry,Air Conditioning,Air Conditioning, Rear,Power Windows,Power Door Locks,Cruise Control,Power Steering,Tilt Wheel,AM/FM Stereo,CD/MP3 (Multi Disc),Audiophile Sound,Sirius Satellite,Parking Sensors,Backup Camera,Dual Air Bags,Side Air Bags,Head Curtain Air Bags,Cooled Seats,Dual Power Seats,Leather,Power Third Row,Fog Lights,Running Boards,Roof Rack,Towing Pkg,Alloy Wheels",
condition: "",
engine: "5.4L V8 SOHC 16V",
drive: "RWD",
mpgCity: "12.00",
mpgHighway: "18.00",
active: true,
display: true
}
}
]
}
>> Time elapsed: 18ms
Thank you for your help!