Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluding keys that have trailing "edges.node" on them #7273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ ___
- Randomize test suite (Diamond Lewis) [#7265](https://github.com/parse-community/parse-server/pull/7265)
- LDAP: Properly unbind client on group search error (Diamond Lewis) [#7265](https://github.com/parse-community/parse-server/pull/7265)
- Improve data consistency in Push and Job Status update (Diamond Lewis) [#7267](https://github.com/parse-community/parse-server/pull/7267)
- Excluding keys that have trailing edges.node when performing GraphQL resolver (Chris Bland) [#7273](https://github.com/parse-community/parse-server/pull/7273)
___
## 4.5.0
[Full Changelog](https://github.com/parse-community/parse-server/compare/4.4.0...4.5.0)
Expand Down
61 changes: 61 additions & 0 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5703,6 +5703,67 @@ describe('ParseGraphQLServer', () => {
result.data.parentClass.graphQLClasses.edges.map(edge => edge.node.objectId)
).toEqual([object3.id, object1.id, object2.id]);
});

it('should support including relation', async () => {
await prepareData();

await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();

const result1 = await apolloClient.query({
query: gql`
query FindRoles {
roles {
edges {
node {
name
}
}
}
}
`,
variables: {},
context: {
headers: {
'X-Parse-Session-Token': user1.getSessionToken(),
},
},
});

const result2 = await apolloClient.query({
query: gql`
query FindRoles {
roles {
edges {
node {
name
users {
edges {
node {
username
}
}
}
}
}
}
}
`,
variables: {},
context: {
headers: {
'X-Parse-Session-Token': user1.getSessionToken(),
},
},
});

expect(result1.data.roles.edges[0].node.name).toBeDefined();
expect(result1.data.roles.edges[0].node.users).toBeUndefined();
expect(result1.data.roles.edges[0].node.roles).toBeUndefined();
expect(result2.data.roles.edges[0].node.name).toBeDefined();
expect(result2.data.roles.edges[0].node.users).toBeDefined();
expect(result2.data.roles.edges[0].node.users.edges[0].node.username).toBeDefined();
expect(result2.data.roles.edges[0].node.roles).toBeUndefined();
});
});
});

Expand Down
1 change: 1 addition & 0 deletions src/GraphQL/loaders/parseClassQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const load = function (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseG
selectedFields
.filter(field => field.startsWith('edges.node.'))
.map(field => field.replace('edges.node.', ''))
.filter(field => field.indexOf('edges.node') < 0)
);
const parseOrder = order && order.join(',');

Expand Down
1 change: 1 addition & 0 deletions src/GraphQL/loaders/parseClassTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ const load = (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLCla
selectedFields
.filter(field => field.startsWith('edges.node.'))
.map(field => field.replace('edges.node.', ''))
.filter(field => field.indexOf('edges.node') < 0)
);
const parseOrder = order && order.join(',');

Expand Down