in Education by
When I'm making a request to my backend through a mutation like that: mutation{ resetPasswordByToken(token:"my-token"){ id } } I'm getting a response in such format: { "data": { "resetPasswordByToken": { "id": 3 } } } And that wrapper object named the same as the mutation seems somewhat awkward (and at least redundant) to me. Is there a way to get rid of that wrapper to make the returning result a bit cleaner? This is how I define the mutation now: export const ResetPasswordByTokenMutation = { type: UserType, description: 'Sets a new password and sends an informing email with the password generated', args: { token: { type: new GraphQLNonNull(GraphQLString) }, captcha: { type: GraphQLString }, }, resolve: async (root, args, request) => { const ip = getRequestIp(request); const user = await Auth.resetPasswordByToken(ip, args); return user.toJSON(); } }; JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In a word: No. resetPasswordByToken is not a "wrapper object", but simply a field you've defined in your schema that resolves to an object (in this case, a UserType). While it's common to request just one field on your mutation type at a time, it's possible to request any number of fields: mutation { resetPasswordByToken(token:"my-token"){ id } someOtherMutation { # some fields here } andYetAnotherMutation { # some other fields here } } If we were to flatten the structure of the response like you suggest, we would not be able to distinguish between the data returned by one mutation from another. We likewise need to nest all of this inside data to keep our actual data separate from any returned errors (which appear in a separate errors entry).

Related questions

0 votes
    I am trying to fetch some data from the GitHub GraphQL but I get a GaphQLError. I have tried the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    We have db collection which is little complicated. Many of our keys are JSON objects where fields aren't ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    How to delete unpublished Git commits and get rid of them permanently? A. git reset –hard B. git revert C. git reset –soft...
asked Dec 20, 2022 in Technology by JackTerrance
0 votes
    This one has been bugging me for a while now. Is there a way I can stop Intellj IDEA from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    Select * from OPENQUERY (PORTAL, ''SELECT st.last AS "Last Name", st.first AS "First Name", ct. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    is there an easy way to not draw this points in my lines? I don't know why this points are ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    How to get rid of Date Filter in Salesforce?...
asked Nov 12, 2020 in Technology by JackTerrance
0 votes
    The Cookies Preferences box that always appears in the bottom right hand corner of the dataplatform.ibm.com ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm wondering, and in need, of strategies that can be applied to reducing low-level locking. However ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    Which of the following is a method of wrapper Float for converting the value of an object into byte? ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of the following is method of wrapper Integer for converting the value of an object into int? (a ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these methods of Byte wrapper can be used to obtain Byte object from a string? (a) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these methods of Character wrapper can be used to obtain the char value contained in Character object ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these methods of Boolean wrapper returns boolean equivalent of an object. (a) getBool() (b) ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
...