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

Implement functions that pull input data from provided argument #30

Open
Kashuab opened this issue Mar 5, 2023 · 0 comments
Open

Implement functions that pull input data from provided argument #30

Kashuab opened this issue Mar 5, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Kashuab
Copy link
Owner

Kashuab commented Mar 5, 2023

The problem with the current implementation in regards to mutation/query args is that you could provide an object that matches the signature of the input type, while accidentally over-saturating the request which would result in a GraphQL error.

For example:

// Imagine this isn't a new post, but came from a query
const post = new PostModel({
  id: 'asdf',
  title: 'blah',
  content: 'beep-boop',
});

const mutation = new UpdatePostMutation({ id: 'asdf', post });

mutation.mutate()

In this case, the updatePost mutation accepts a post within UpdatePostInput, containing title and content but NOT id, as that's a separate argument. This code is type-safe but would produce a GraphQL error at runtime. Ideally, there would be auto-generated functions that would gatekeep what data goes into the mutation/query args.

For example:

const mutation = new UpdatePostMutation(
  filterUpdatePostMutationInput({ id: 'asdf', post })
);

Ideally, this implementation detail would be taken care of by the auto-generated mutations/queries.
Actually, no, I think this should be manually implemented. Trying to do too much "automatically" could make the code hard to understand when taken at face value.

@Kashuab Kashuab added this to the Version 0.1.0 milestone Mar 5, 2023
@Kashuab Kashuab self-assigned this Mar 5, 2023
@Kashuab Kashuab added the pre-release Critical issues before the first supported release on NPM. label Mar 5, 2023
@Kashuab Kashuab added enhancement New feature or request and removed pre-release Critical issues before the first supported release on NPM. labels Mar 18, 2023
@Kashuab Kashuab removed this from the Version 0.1.0 milestone Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant