-
Notifications
You must be signed in to change notification settings - Fork 6
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
Make passing in the params by model api identifier optional #178
Conversation
Nice. This deals with the internal API. Do we have plans to do something similar for the public API? |
We certainly do! https://github.com/gadget-inc/gadget/pull/6455 |
f083e9d
to
95da719
Compare
f018847
to
bd350a3
Compare
ready for another review. this was updated to throw an error if the flat style is used and the model has ambiguous identifiers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
} | ||
|
||
if (this.apiIdentifier in record) { | ||
recordData = recordData[this.apiIdentifier]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks like we don't have any codepath that could have extra params in the internal API right now, but we'll have to remember that if that changes in the future this would potentially break (since it would clobber those params). Very likely we'd catch that kind of change in CI.
) { | ||
this.capitalizedApiIdentifier = camelize(apiIdentifier); | ||
} | ||
|
||
private validateRecord(record: RecordData) { | ||
if (!this.options || !this.options.hasAmbiguousIdentifiers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
bd350a3
to
e440850
Compare
…ate mutations optional
e440850
to
800ddcf
Compare
This PR makes it optional to wrap your model params for create/update in the model api identifier. The only exception is if there is a field with the same api identifier as the model, then the params must be wrapped in the model api identifier; this is because there's no way to tell if the consumer is passing in model params or field value.
It would be nice to be able to test that the correct query/variables are called but the mutations rely on transactions via ws. This is a bit difficult to mock I think without adding some interfaces so that we can create a mock transaction, not sure if that was worth adding here.
PR Checklist