Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

node.js - Is it possible to solve GraphQL Partial Update By Generate fieldname and new data from function parameter

I searched around and didn't see any good solution for partial update in GraphQL.

My goal was like call only 1 mutation method, and lets say that I got 15 fields that from the object. And I only want to update 3 out of 15. So I only pass in the those 3 fields with value, and I knew that rest will be pass in as null/defined.

I wonder that can I generate the name of the field base on the input?

Code Below

function partialUpdate(id, feild, data) {
    console.log("Triggered Partial update: " + data);
    Quest.findByIdAndUpdate(id, {
        $set: {
            feild: data
        }
    }, { new: true }).exec();
}
question from:https://stackoverflow.com/questions/65836563/is-it-possible-to-solve-graphql-partial-update-by-generate-fieldname-and-new-dat

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...