-
Notifications
You must be signed in to change notification settings - Fork 156
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
[feature] Change mutation API to remove requirement to return all values except ID #1116
Comments
Oh this would be neat for Postgres since upserts can only return IDs and currently require a separate query to fetch the actual record. However, bulk upserts still require a separate query. |
I'd say it should be |
I can take this. |
Happy to help you, answer any question you have to solve this issue. Looking forward for a PR for this! |
@mihaimaruseac Could I please know what files I should look at to get a better understanding of what needs changes? |
I took a look at this issue and have reached this understanding. The GraphQL mutations are to be edited to return a String! or a [String!]! and instead of returning the struct array or struct array in the mutationresolvers, we return the string IDs. Please correct me if my understanding is off here. Thanks! |
yes that is correct so all the changes need to happen here on the server side: https://github.com/guacsec/guac/tree/main/pkg/assembler/graphql/schema (for all that contain a mutation) and on the client side: https://github.com/guacsec/guac/tree/main/pkg/assembler/clients/operations For the Server side, all mutations have to change to: For Example:
For Client side, all the mutations will change to expect a return of an ID: For example:
After that you need to regenerate the code: |
That answered my queries as well. Thank you, @pxp928 . I'll try to send a PR soon. |
Sorry, been travelling. @pxp928 's answer is complete |
Could I get some insight on this error, please? |
What have you changed so far @arorasoham9? Based on that we can figure out where the error is coming from. Are you working on a branch that we can look at the diff? |
@pxp928 This is what I have for now arorasoham9@7a7c2c6 |
hmmm it's a strange error. @mihaimaruseac any thoughts why this would happen? I am looking into it more... |
I am guessing the fix is to use the spread operator like so.
|
No this does not work. I just tried it |
I think because we return a scalar we don't need anything in |
@arorasoham9 looks like just doing:
works Thanks @mihaimaruseac! |
We'll need to update examples too, in case we look at the values generated from the ingestion |
Can I safely ignore these errors that appear after I run
I believe they are coming from the resolvers that require the return value changed. |
I think so too. |
Yes you can update the resolver based on updating the backend interface. |
Re-opening issue as updates need to be made to the backends to only return the IDs (currently returning the actual model object) |
Marking this issue as complete and follow-up work will be done in the issues referenced above. |
Worth having a branch in the repo (e.g. WDYT? |
sure that sounds good, here is the branch - https://github.com/guacsec/guac/tree/1116-return-ID |
created #1285 for changing the |
Is your feature request related to a problem? Please describe.
Change mutation APIs to remove requirement to return the entire struct, but instead just IDs. This will make it so that mutations will have better execution time as usually results in INSERTs being used instead of UPSERTs with a followup retrieval if necessary.
A field is still required since GraphQL requires a return statement.
This stems from efforts in the #910, as well as some optimization efforts for implementation in ArangoDB.
Describe the solution you'd like
For each mutation like the following example for HasSBOM, go from
to
Describe alternatives you've considered
Return a boolean instead. However IDs are still usable. If the ID is not returnable, returning an empty string is also fine.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: