fix(dataconnect): Refactor CRUD helpers to use GraphQL variables and @allow directive#3182
Open
stephenarosaj wants to merge 12 commits into
Open
fix(dataconnect): Refactor CRUD helpers to use GraphQL variables and @allow directive#3182stephenarosaj wants to merge 12 commits into
stephenarosaj wants to merge 12 commits into
Conversation
… artifact ignores
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the Data Connect API client to use GraphQL variables and the @allow(fields: ...) directive for insert, insertMany, upsert, and upsertMany operations, replacing the previous manual JSON-to-GraphQL-string serialization. It also updates the unit tests to validate this new variable-based execution and adds Data Connect emulator testing instructions to the contribution guide. The review feedback highlights potential GraphQL injection vulnerabilities and syntax errors due to direct interpolation of table names and object keys into the mutation strings, recommending validation against standard GraphQL identifier patterns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
✨ Refactored Data Connect CRUD operations to execute parameterized GraphQL mutations with query variables and
@allowdirectives. This fixes the bug described by Issue #3041 where enums would not be serialized properly by the[insert,upsert](many)APIs.To verify this fix and harden integration tests, refactored tests so that before checking for equality between the expected and actual input query strings, they are normalized.
Also updated integration testing instructions and
.gitignore.Changes
objectToStringinline GraphQL serializergetTableNames,getObjectKeys, andgetArrayObjectsKeyshelpersinsert,insertMany,upsert,upsertMany) to use GraphQL variables and@allowdirectivesCONTRIBUTING.md.gitignoreso that no matter where they show up, they are properly ignored. This makes it so that even when running integration tests from the root of the SDK repo they are not tracked.Testing
expectNormalizedExecuteGraphqlCalltest helper@allowdirectives