Skip to content

Commit 0811537

Browse files
authored
Merge pull request #126 from weaviate/cursor-api
Support cursor API in REST and GraphQL
2 parents 1d507b6 + daf944f commit 0811537

14 files changed

+147
-50
lines changed

ci/docker-compose-azure-cc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- --scheme
1212
- http
1313
- --write-timeout=600s
14-
image: semitechnologies/weaviate:1.18.0-alpha.0-be532d2
14+
image: semitechnologies/weaviate:1.18.0-alpha.1-41f7cb9
1515
ports:
1616
- 8081:8081
1717
restart: on-failure:0

ci/docker-compose-okta-cc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0-alpha.0-be532d2
13+
image: semitechnologies/weaviate:1.18.0-alpha.1-41f7cb9
1414
ports:
1515
- 8082:8082
1616
restart: on-failure:0

ci/docker-compose-okta-users.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0-alpha.0-be532d2
13+
image: semitechnologies/weaviate:1.18.0-alpha.1-41f7cb9
1414
ports:
1515
- 8083:8083
1616
restart: on-failure:0

ci/docker-compose-wcs-noscope.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0-alpha.0-be532d2
13+
image: semitechnologies/weaviate:1.18.0-alpha.1-41f7cb9
1414
ports:
1515
- 8086:8086
1616
restart: on-failure:0

ci/docker-compose-wcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- --scheme
1111
- http
1212
- --write-timeout=600s
13-
image: semitechnologies/weaviate:1.18.0-alpha.0-be532d2
13+
image: semitechnologies/weaviate:1.18.0-alpha.1-41f7cb9
1414
ports:
1515
- 8085:8085
1616
restart: on-failure:0

ci/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
version: '3.4'
33
services:
44
weaviate:
5-
image: semitechnologies/weaviate:1.18.0-alpha.0-be532d2
5+
image: semitechnologies/weaviate:1.18.0-alpha.1-41f7cb9
66
restart: on-failure:0
77
ports:
88
- "8080:8080"

cluster/journey.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const weaviate = require("../index");
22
const { createTestFoodSchemaAndData, cleanupTestFood, PIZZA_CLASS_NAME, SOUP_CLASS_NAME } = require("../utils/testData");
33

4-
const EXPECTED_WEAVIATE_VERSION = "1.18.0-alpha.0"
5-
const EXPECTED_WEAVIATE_GIT_HASH = "be532d2"
4+
const EXPECTED_WEAVIATE_VERSION = "1.18.0-alpha.1"
5+
const EXPECTED_WEAVIATE_GIT_HASH = "41f7cb9"
66

77
describe("cluster nodes endpoint", () => {
88
const client = weaviate.client({

data/getter.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default class Getter {
1111
return this;
1212
};
1313

14+
withAfter = (id) => {
15+
this.after = id;
16+
return this;
17+
};
18+
1419
withLimit = (limit) => {
1520
this.limit = limit;
1621
return this;
@@ -32,7 +37,8 @@ export default class Getter {
3237
);
3338
}
3439

35-
return this.objectsPath.buildGet(this.className, this.limit, this.additionals)
40+
return this.objectsPath.buildGet(this.className, this.limit,
41+
this.additionals, this.after)
3642
.then(this.client.get);
3743
};
3844
}

data/journey.test.js

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ describe("data", () => {
6565

6666
it("creates a new thing object with an explicit id", () => {
6767
const properties = { stringProp: "with-id" };
68-
const id = "1565c06c-463f-466c-9092-5930dbac3887";
68+
// explicitly make this an all-zero UUID. This way we can be sure that it's
69+
// the first to come up when using the cursor API. Since this test suite
70+
// also contains dynamicaly generated IDs, this is the only way to make
71+
// sure that this ID is first. This way the tests returning objects after
72+
// this ID won't be flaky.
73+
const id = "00000000-0000-0000-0000-000000000000";
6974

7075
return client.data
7176
.creator()
@@ -128,7 +133,7 @@ describe("data", () => {
128133
expect(res.objects).toEqual(
129134
expect.arrayContaining([
130135
expect.objectContaining({
131-
id: "1565c06c-463f-466c-9092-5930dbac3887",
136+
id: "00000000-0000-0000-0000-000000000000",
132137
properties: { stringProp: "with-id" },
133138
}),
134139
expect.objectContaining({
@@ -150,7 +155,7 @@ describe("data", () => {
150155
expect(res.objects).toEqual(
151156
expect.arrayContaining([
152157
expect.objectContaining({
153-
id: "1565c06c-463f-466c-9092-5930dbac3887",
158+
id: "00000000-0000-0000-0000-000000000000",
154159
properties: { stringProp: "with-id" },
155160
}),
156161
expect.objectContaining({
@@ -162,6 +167,26 @@ describe("data", () => {
162167
.catch((e) => fail("it should not have errord: " + e));
163168
});
164169

170+
it("gets all classes after a specfic object (Cursor API)", () => {
171+
return client.data
172+
.getter()
173+
.withClassName(thingClassName)
174+
.withLimit(100)
175+
.withAfter("00000000-0000-0000-0000-000000000000")
176+
.do()
177+
.then((res) => {
178+
expect(res.objects).toHaveLength(1);
179+
expect(res.objects).toEqual(
180+
expect.arrayContaining([
181+
expect.objectContaining({
182+
properties: { stringProp: "without-id" },
183+
}),
184+
])
185+
);
186+
})
187+
.catch((e) => fail("it should not have errord: " + e));
188+
});
189+
165190
it("gets all things with all optional _additional params", () => {
166191
return client.data
167192
.getter()
@@ -207,12 +232,12 @@ describe("data", () => {
207232
it("gets one thing by id only", () => {
208233
return client.data
209234
.getterById()
210-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
235+
.withId("00000000-0000-0000-0000-000000000000")
211236
.do()
212237
.then((res) => {
213238
expect(res).toEqual(
214239
expect.objectContaining({
215-
id: "1565c06c-463f-466c-9092-5930dbac3887",
240+
id: "00000000-0000-0000-0000-000000000000",
216241
properties: { stringProp: "with-id" },
217242
})
218243
);
@@ -224,12 +249,12 @@ describe("data", () => {
224249
return client.data
225250
.getterById()
226251
.withClassName(thingClassName)
227-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
252+
.withId("00000000-0000-0000-0000-000000000000")
228253
.do()
229254
.then((res) => {
230255
expect(res).toEqual(
231256
expect.objectContaining({
232-
id: "1565c06c-463f-466c-9092-5930dbac3887",
257+
id: "00000000-0000-0000-0000-000000000000",
233258
properties: { stringProp: "with-id" },
234259
})
235260
);
@@ -241,7 +266,7 @@ describe("data", () => {
241266
return client.data
242267
.getterById()
243268
.withClassName("DoesNotExist")
244-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
269+
.withId("00000000-0000-0000-0000-000000000000")
245270
.do()
246271
.catch(err =>
247272
expect(err).toEqual("usage error (404): ")
@@ -251,7 +276,7 @@ describe("data", () => {
251276
it("gets one thing by id with all optional additional props", () => {
252277
return client.data
253278
.getterById()
254-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
279+
.withId("00000000-0000-0000-0000-000000000000")
255280
.withAdditional("classification")
256281
.withAdditional("interpretation")
257282
.withAdditional("nearestNeighbors")
@@ -282,7 +307,7 @@ describe("data", () => {
282307
});
283308

284309
it("updates a thing by id only", () => {
285-
const id = "1565c06c-463f-466c-9092-5930dbac3887";
310+
const id = "00000000-0000-0000-0000-000000000000";
286311
return client.data
287312
.getterById()
288313
.withId(id)
@@ -307,7 +332,7 @@ describe("data", () => {
307332
});
308333

309334
it("updates a thing by id and class name", () => {
310-
const id = "1565c06c-463f-466c-9092-5930dbac3887";
335+
const id = "00000000-0000-0000-0000-000000000000";
311336
return client.data
312337
.getterById()
313338
.withId(id)
@@ -332,7 +357,7 @@ describe("data", () => {
332357
});
333358

334359
it("merges a thing", () => {
335-
const id = "1565c06c-463f-466c-9092-5930dbac3887";
360+
const id = "00000000-0000-0000-0000-000000000000";
336361
return client.data
337362
.getterById()
338363
.withId(id)
@@ -353,7 +378,7 @@ describe("data", () => {
353378

354379
it("adds a reference to a thing by id only", () => {
355380
const sourceId = "599a0c64-5ed5-4d30-978b-6c9c45516db1";
356-
const targetId = "1565c06c-463f-466c-9092-5930dbac3887";
381+
const targetId = "00000000-0000-0000-0000-000000000000";
357382

358383
return client.data
359384
.referenceCreator()
@@ -398,7 +423,7 @@ describe("data", () => {
398423

399424
it("adds a reference to a thing by id and class name", () => {
400425
const sourceId = "599a0c64-5ed5-4d30-978b-6c9c45516db1";
401-
const targetId = "1565c06c-463f-466c-9092-5930dbac3887";
426+
const targetId = "00000000-0000-0000-0000-000000000000";
402427

403428
return client.data
404429
.referenceCreator()
@@ -447,7 +472,7 @@ describe("data", () => {
447472
it("checks that object exists by id only", () => {
448473
return client.data
449474
.checker()
450-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
475+
.withId("00000000-0000-0000-0000-000000000000")
451476
.do()
452477
.then((exists) => {
453478
if (!exists) {
@@ -460,7 +485,7 @@ describe("data", () => {
460485
it("checks that object exists by id and class name", () => {
461486
return client.data
462487
.checker()
463-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
488+
.withId("00000000-0000-0000-0000-000000000000")
464489
.withClassName(thingClassName)
465490
.do()
466491
.then((exists) => {
@@ -474,15 +499,15 @@ describe("data", () => {
474499
it("deletes a thing by id only", () => {
475500
return client.data
476501
.deleter()
477-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
502+
.withId("00000000-0000-0000-0000-000000000000")
478503
.do()
479504
.catch((e) => fail("it should not have errord: " + e));
480505
});
481506

482507
it("checks that object doesn't exist anymore with delete by id only", () => {
483508
return client.data
484509
.checker()
485-
.withId("1565c06c-463f-466c-9092-5930dbac3887")
510+
.withId("00000000-0000-0000-0000-000000000000")
486511
.do()
487512
.then((exists) => {
488513
if (exists) {
@@ -585,7 +610,7 @@ describe("data", () => {
585610
});
586611

587612
it("forms a get by id query with node_name set", () => {
588-
const id = "1565c06c-463f-466c-9092-5930dbac3887";
613+
const id = "00000000-0000-0000-0000-000000000000";
589614

590615
return client.data
591616
.getterById()
@@ -602,7 +627,7 @@ describe("data", () => {
602627
})
603628

604629
it("forms a get by id query with consistency_level set", () => {
605-
const id = "1565c06c-463f-466c-9092-5930dbac3887";
630+
const id = "00000000-0000-0000-0000-000000000000";
606631

607632
return client.data
608633
.getterById()

data/path.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export class ObjectsPath {
2222
return this.build({id, className, additionals, consistencyLevel, nodeName},
2323
[this.addClassNameDeprecatedNotSupportedCheck, this.addId, this.addQueryParams]);
2424
}
25-
buildGet(className, limit, additionals) {
26-
return this.build({className, limit, additionals}, [this.addQueryParamsForGet]);
25+
buildGet(className, limit, additionals, after) {
26+
return this.build({className, limit, additionals, after}, [this.addQueryParamsForGet]);
2727
}
2828
buildUpdate(id, className, consistencyLevel) {
2929
return this.build({id, className, consistencyLevel},
@@ -103,6 +103,9 @@ export class ObjectsPath {
103103
support.warns.notSupportedClassParameterInEndpointsForObjects();
104104
}
105105
}
106+
if (isValidStringProperty(params.after)) {
107+
queryParams.push(`after=${params.after}`)
108+
}
106109
if (queryParams.length > 0) {
107110
return `${path}?${queryParams.join("&")}`;
108111
}

0 commit comments

Comments
 (0)