-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Hello, array types in RxSchema cannot build correct GraphQL query in replication.
This patch is fixing the wrong query. Maybe you can add it to next release.
diff --git a/node_modules/rxdb/dist/esm/plugins/replication-graphql/query-builder-from-rx-schema.js b/node_modules/rxdb/dist/esm/plugins/replication-graphql/query-builder-from-rx-schema.js
index 3dc67b1..85d8077 100644
--- a/node_modules/rxdb/dist/esm/plugins/replication-graphql/query-builder-from-rx-schema.js
+++ b/node_modules/rxdb/dist/esm/plugins/replication-graphql/query-builder-from-rx-schema.js
@@ -111,7 +111,13 @@ function generateGQLOutputFields(options) {
continue;
}
var value = properties[key];
- if (value.type === "object") {
+ if (value.type === "array") {
+ outputFields.push(LINE_SPACING + NESTED_SPACING + key + " {", generateGQLOutputFields({
+ schema: value.items,
+ spaceCount,
+ depth: depth + 1
+ }), LINE_SPACING + NESTED_SPACING + "}");
+ } else if (value.type === "object") {
outputFields.push(LINE_SPACING + NESTED_SPACING + key + " {", generateGQLOutputFields({
schema: value,
spaceCount,
diff --git a/node_modules/rxdb/src/plugins/replication-graphql/query-builder-from-rx-schema.ts b/node_modules/rxdb/src/plugins/replication-graphql/query-builder-from-rx-schema.ts
index 12f86a4..2edc338 100644
--- a/node_modules/rxdb/src/plugins/replication-graphql/query-builder-from-rx-schema.ts
+++ b/node_modules/rxdb/src/plugins/replication-graphql/query-builder-from-rx-schema.ts
@@ -170,6 +170,13 @@ function generateGQLOutputFields(options: GenerateGQLOutputFieldsOptions) {
}
const value = properties[key];
+ if (value.type === "array" && value.items) {
+ outputFields.push(
+ LINE_SPACING + NESTED_SPACING + key + " {",
+ generateGQLOutputFields({ schema: value.items, spaceCount, depth: depth + 1 }),
+ LINE_SPACING + NESTED_SPACING + "}"
+ );
+ }
if (value.type === "object") {
outputFields.push(
LINE_SPACING + NESTED_SPACING + key + " {",
Metadata
Metadata
Assignees
Labels
No labels