Skip to content

Commit b77a24b

Browse files
committed
removed redundant logic and moved comments to outside for posterity
1 parent 66182ce commit b77a24b

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/GraphQL/loaders/parseClassQueries.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ const load = function (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseG
107107
const { keys, include } = extractKeysAndInclude(
108108
selectedFields
109109
.filter(field => field.startsWith('edges.node.'))
110-
.map(field => field.replace('edges.node.', ''))
111-
.map(field => field.replace(/\.edges\.node/g, ''))
110+
// GraphQL relation connections expose data under `edges.node.*`. Those
111+
// segments do not correspond to actual Parse fields, so strip them to
112+
// ensure the root relation key remains in the keys list (e.g. convert
113+
// `users.edges.node.username` -> `users.username`). This preserves the
114+
// synthetic relation placeholders that Parse injects while still
115+
// respecting field projections.
116+
.map(field => field.replace('edges.node.', '').replace(/\.edges\.node/g, ''))
112117
.filter(field => field.indexOf('edges.node') < 0)
113118
);
114119
const parseOrder = order && order.join(',');

src/GraphQL/loaders/parseClassTypes.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,11 @@ const load = (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLCla
351351
...defaultGraphQLTypes.PARSE_OBJECT_FIELDS,
352352
...(className === '_User'
353353
? {
354-
authDataResponse: {
355-
description: `auth provider response when triggered on signUp/logIn.`,
356-
type: defaultGraphQLTypes.OBJECT,
357-
},
358-
}
354+
authDataResponse: {
355+
description: `auth provider response when triggered on signUp/logIn.`,
356+
type: defaultGraphQLTypes.OBJECT,
357+
},
358+
}
359359
: {}),
360360
};
361361
const outputFields = () => {
@@ -386,8 +386,13 @@ const load = (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLCla
386386
const { keys, include } = extractKeysAndInclude(
387387
selectedFields
388388
.filter(field => field.startsWith('edges.node.'))
389-
.map(field => field.replace('edges.node.', ''))
390-
.map(field => field.replace(/\.edges\.node/g, ''))
389+
// GraphQL relation connections expose data under `edges.node.*`. Those
390+
// segments do not correspond to actual Parse fields, so strip them to
391+
// ensure the root relation key remains in the keys list (e.g. convert
392+
// `users.edges.node.username` -> `users.username`). This preserves the
393+
// synthetic relation placeholders that Parse injects while still
394+
// respecting field projections.
395+
.map(field => field.replace('edges.node.', '').replace(/\.edges\.node/g, ''))
391396
.filter(field => field.indexOf('edges.node') < 0)
392397
);
393398
const parseOrder = order && order.join(',');

src/GraphQL/parseGraphQLUtils.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ export function toGraphQLError(error) {
2222
export const extractKeysAndInclude = selectedFields => {
2323
selectedFields = selectedFields
2424
.filter(field => !field.includes('__typename'))
25-
// GraphQL relation connections expose data under `edges.node.*`. Those
26-
// segments do not correspond to actual Parse fields, so strip them to
27-
// ensure the root relation key remains in the keys list (e.g. convert
28-
// `users.edges.node.username` -> `users.username`). This preserves the
29-
// synthetic relation placeholders that Parse injects while still
30-
// respecting field projections.
31-
.map(field => field.replace(/\.edges\.node/g, ''));
25+
3226
// Handles "id" field for both current and included objects
3327
selectedFields = selectedFields.map(field => {
3428
if (field === 'id') { return 'objectId'; }

0 commit comments

Comments
 (0)