Page tree
Skip to end of metadata
Go to start of metadata

The architecture for a mutation is to pass in an input object and one or more return objects to define what data a successful mutation should return. Because a mutation also makes a query, it is recommended you read GraphQL Queries section first.

The input object is an implementation of the IDataSenderBuilder interface, InputDataSenderBuilder. Most mutations expect objects, so take an InputDataSenderBuilder. This is a Java object containing the mutationName and the fieldsMap, a Map of field keys and values which contains the content being passed.The fields are defined in an enum in the relevant GraphQLMutation.

In addition, one of more return objects also need to be passed, to determine the content to return from the query. These return objects also implement the IDataSenderBuilder interface and define what should be returned. Unlike queries, the response may be an object or it may be just a single scalar json value. Consequently, there are two different classes that a return object may be, an ObjectDataSenderBuilder and a ScalarDataSenderBuilder. See specific mutations for further details.

The input and output objects are passed into the mutation object, a class extending BaseGraphQLMutation (the mutation equivalent of what exists for queries, the BaseGraphQLQuery). This is passed to a GraphQLRequest, which is added as the request for an endpoint. This process should be familiar from queries. There are also helper methods from the WWClient class to reduce the complexity of layers.

The following code block will demonstrate the full process (this is a WWClient object that corresponds to an authenticated WWClient).

updateSpace
ArrayList<String> members = new ArrayList<String>();
members.add("ae81bc5d-70fa-4bdb-bab7-29f4df10ddf3y");
InputDataSenderBuilder spaceInput = new InputDataSenderBuilder(Space.UPDATE_SPACE_MUTATION_NAME);
spaceInput.addField(UpdateSpaceFields.ID, spaceId);
spaceInput.addField(UpdateSpaceFields.TITLE, "My new title");
spaceInput.addField(UpdateSpaceFields.MEMBERS, members);
spaceInput.addField(UpdateSpaceFields.MEMBER_OPERATION, UpdateSpaceMemberOperation.ADD);
ObjectDataSenderBuilder returnObject1 = new ObjectDataSenderBuilder(Space.ONE_SPACE_QUERY_OBJECT_NAME);
returnObject1.addField(SpaceFields.TITLE);
ScalarDataSenderBuilder returnObject2 = new ScalarDataSenderBuilder(MEMBER_IDS_CHANGED_FIELD);
SpaceUpdateGraphQLMutation mutationObject = new SpaceUpdateGraphQLMutation(spaceInput, returnObject1, returnObject2);
ep.setRequest(new GraphQLRequest(mutationObject));
ep.executeRequest();
UpdateSpaceContainer output = ep.getResultContainer().getData().getUpdateSpaceContainer()

Lines 1-2 create an ArrayList containing the single member we want to add to access for the Space.

Lines 3 - 7 create the InputDataSenderBuilder, passing the ID of the space we want to update, the title we want to rename the space with, the members we want to update and the "ADD" enum to tell Watson Workspace we want to add rather than remove this user.

Lines 8 - 9 create an ObjectDataSenderBuilder which is a very basic getSpace query to return the space's title. Unlike the normal getSpace query, we don't need to ask for the ID of which space to return. We're returning data for the space we're updating in the mutation.

Line 10 creates a ScalarDataSenderBuilder to echo the array of members updated.

Line 11 passes the input object and the two return objects into a new instance of a class extending BaseGraphQLMutation. Classes are available for all query types and will create a default method name, e.g. "updateSpace".

Line 12 passes the query object into a new GraphQLRequest, and sets this as the request for the GraphQLEndpoint. Line 20 executes the request.

Line 14 then uses GSON to parse the result container and get an UpdateSpaceContainer which will contain the Space and an array of the member ids changed. Lines 12 - 14 could be reduced into a single line by using a helper method from the WWClient class that takes just the new instance of a class extending BaseGraphQLQuery:

UpdateSpaceContainer result = client.updateSpaceWithMutation(new GraphQLRequest(mutationObject));

On occasion a mutation may only accept fixed input and only return a fixed output. The deleteSpace mutation is one such mutation. As a result, there are no methods for passing input and output objects, just simple methods in WWClient.

36 Comments

  1. Anonymous


    Do more with OneDrive and Office 365 Create polished documents, http://enter-office.com/setup]office  unlock insights, present with clarity, and collaborate in real-time using Office 365.


  2. Anonymous

    Fix printer problems in Windows 10. When you connect a printer to your PC or add a new printer to your home network, you can usually start printing right away. http://fixprinterproblemsinwindows10.com Windows supports most printers, and you probably won't have to go out of your way to install special printer software.

  3. Anonymous

    Install mcafee product without any hassle. We provide best installation service click here for more details : http://mcafeecom-mcafee.com

  4. Anonymous

    office it the package of office tools to make your working smooth and effective. http://msofficecom.com/contact-us Get it downloaded in your computer with the fast help.



  5. Anonymous

    Exceptional technical assistance for setting up office 365 in your computer or laptop. http://my-officecom.us just give us a call on our number and we are ready to give you the best help.

  6. Anonymous

    Present norton antivirus with the best help gathering and keep your PC contamination free. http://norto-n.com/setup Download norton antivirus with the best help gathering and avoid disease attacks.

  7. Anonymous

    To get started Office 2019, http://officecommyaccount.net   2016 and office 365 download or installation you must need valid 25 character product key,


  8. Anonymous

    Webroot is a best-known antivirus software protects your devices against phishing, ransom attacks, viruses and malwares. visit here for more details : http://webrootinstall.me It can keep your data, files and essential information safe and also scan your files against online threat.


  9. Anonymous

    Here you can get item keys for Office 365 full form and individual Office apps. https://msoftoffice.com/install-office Here we are giving full help to introduce office bundle click here for more subtleties.

  10. Anonymous

    norton help to ensure your gadgets against antiviruses https://symnorton.com/setup and offer security to client and giving personality and contraption affirmation to your related life.

  11. Anonymous

    mcafee antivirus is widely used aantivirus helps to detect and neutralize computer virus, the mail worms,the trojan programs,and also helps your system free of virus and other malware is quite a daily challenge. for more details  visit https://mtmcafee.com/activate  here.


  12. Anonymous

    Get started with Office product by downloading and installing it. http://office.com-setup-setup.support Type the product key at




  13. Anonymous

    Norton Setup Internet and Device Security. https://xnorton.com Norton give total seCurity to web and device.Every business constantly expected to send the record and subtleties material and everybody needs to beyond any doubt that the archives that are sending the best possible and unique arrangement.



  14. Anonymous

    To stop the malware from damaging the folders on the device,http://mcafee.com-activate.store  McAfee Antivirus software has to be downloaded in the device. After downloading the McAfee Antivirus, the protection for the system data automatically gets started.

  15. Anonymous

    On the off chance that you need to reinstall office or fix it,  http://argoffice.com you can reverify your item key on setup page and can download more established form of office



  16. Anonymous

    Every people should read this post at least once.  I definitely looking forward for more informative posts.

    Ida Wallace, Senior Assignment Writer, http://www.assignmenthelpfolks.com/

  17. Anonymous

    Such a knowledgeable post about Building Mutations with the SDK. I am happy to found this post.

    William Riley, http://www.eliteassignment.co.uk/finance/

  18. Anonymous

    Such an amazing post. I am glad to found this post and I enjoyed to read it.

    Jack Ponting, Assistant Dissertation Writer

    http://www.qualitydissertation.co.uk/

  19. Anonymous

    Roku gives the least troublesome way to deal with stream redirection to your TV.  https://activateroku.net   On your terms  With countless channels to peruse.

  20. Anonymous


    Steps to Activate Avg retail enlistment Once you install AVG retail activation on your framework, you require to activate it as without activation it is extraordinary to get its feature.  https://avg.comretail.net   In this way, enact AVG antivirus by following given advances carefully.

  21. Anonymous


    After you buy Norton Antivirus visit   https://de-norton.com  sign in to norton account then enter norton product for Norton Setup or Install Norton Antivirus

  22. Anonymous


    norton com  download, establishment and enactment.  https://de-norton.com/setup/   The web slanted world structures the need of an antivirus that can verify your data and besides ensure safe taking a gander at and what's more guaranteed trades over the web

  23. Anonymous

    This is least troublesome approach to manage stream actuation to your TV.  https://device-roku.com   On your terms. Wit h an extensive number of accessible channels to research for more details.visit:  today.

  24. Anonymous


     Steps to interface your Player to your TV.   https://device-roku.com/link/   Roku activate device is the easiest method to stream stimulation to your TV. visit for roku .

  25. Anonymous


     offer total security of sensitive files over the entirety of your gadgets that incorporate a wide range of IOS gadgets,   https://docs-webroot.com   OS gadgets just as Android devices.

  26. Anonymous

    webroot cyber security is a ultimate internet security suite for complete protection against today's diverse range of threat on windows. key features are 100% secure secure shopping, 1 click virus scanning,  https://docs-webroot.com/safe   malicious website filtering, unblock antivirus.if you want to install it then visit our site:

  27. Anonymous


    Download norton antivirus to make your computer virus free with the best support and tech team.   https://es-norton.com   Feel free to contact us

  28. Anonymous

    To enact the Norton setup, select the Activate Now option at the base. To recharge the membership for Norton, select the Help choice and snap on Enter item key. Cautiously type the right Norton item key in the clear.  https://es-norton.com/setup/  Snap on the Next catch.Go through with  for more details.

  29. Anonymous


    webroot is a light weighted software,install extreme digital security at webroot safe or at webroot safe introduce   https://geekwebroot.com   click here to download webroot safe.

  30. Anonymous


    Much obliged to you for picking Webroot web security.   https://geekwebroot.com/safe/   You're nearly secured! Essentially complete the accompanying strides beneath to finish your introduce.

  31. Anonymous


    Webroot Antivirus Software Installation Requirements As we realize that Webroot is security programming and antivirus that give a   https://geek-www-webroot.com   high-class insurance to both individual and expert use.

  32. Anonymous

    It is all time best protective  antivirus and anti-spyware .It is real time protection  technology and it is safer ,   https://geek-www-webroot.com/safe/   faster and more complete than ever before.if  want to install it then visit our site.

  33. Anonymous

    It is all time best protective  antivirus and anti-spyware .It is real time protection  technology and it is safer ,   https://geek-www-webroot.com/safe/   faster and more complete than ever before.if  want to install it then visit our site.

  34. Anonymous

    I am so happy to found this website and I also got very informative contents from this website. Thanks for sharing always informative contents with us.

    Regards 

    Secure Assignment Help

  35. Anonymous

    Firstly I thankful to an author for sharing this very helpful post with us about Building Mutations with the SDK with the code.

    Emily Brown, http://www.dissertationhelp.uk/marketing-dissertation/

Write a comment…