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

feat: Provide parent data when resolving with cloud function #8795

Open
wants to merge 2 commits into
base: release-5.x.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Added test and always return className as string
  • Loading branch information
Benjamin Schulz committed Oct 30, 2023
commit c23fcb40f757639616d5da6d51d9915d7769613d
22 changes: 22 additions & 0 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10603,6 +10603,9 @@ describe('ParseGraphQLServer', () => {
hello3: String! @mock(with: "Hello world!")
hello4: User! @mock(with: { username: "somefolk" })
}
extend type User {
hasParentData: Boolean! @resolve
}
`,
});
parseGraphQLServer.applyGraphQL(expressApp);
Expand Down Expand Up @@ -10704,6 +10707,25 @@ describe('ParseGraphQLServer', () => {
})
).toBeResolved();
});

it('provides parent data when resolving a field', async () => {
let parent;
Parse.Cloud.define('hasParentData', async req => {
parent = req.parent;
return true;
});
await apolloClient.query({
query: gql`
query {
hello4 {
hasParentData
}
}
`,
});
expect(parent.className).toEqual('User');
expect(parent.username).toEqual('somefolk');
});
});

describe('GraphQL Schema Based', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/loaders/schemaDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const load = parseGraphQLSchema => {
info,
body: args,
parent: {
className: gqlInfo?.parentType,
className: String(gqlInfo.parentType),
..._source,
},
})
Expand Down