Esempio n. 1
0
        /// <summary>
        /// Allows you to build and send custom GraphQL mutation queries to the Storefront API.
        /// </summary>
        /// <param name="buildQuery">delegate that will build a query starting at <see ref="QueryRootQuery">MutationQuery </see></param>
        /// <param name="callback">callback which will receive a response</param>
        /// \code
        /// // Example that creates a new customer on a store
        /// ShopifyBuy.Client().Mutation(
        ///     buildQuery: (mutation) => { mutation
        ///         .customerCreate(
        ///             buildQuery: (cc) => { cc
        ///                 .userErrors(
        ///                     buildQuery: (ue) => { ue
        ///                         .field()
        ///                         .message();
        ///                     }
        ///                 );
        ///             },
        ///             input: new CustomerCreateInput(
        ///                 email: "*****@*****.**",
        ///                 password: "******"
        ///             )
        ///         );
        ///     },
        ///     callback: (data, error) => {
        ///         if (error != null) {
        ///             Debug.Log("There was an error: " + error.Reason);
        ///         } else {
        ///             List<UserError> userErrors = data.customerCreate().userErrors();
        ///
        ///             if (userErrors != null) {
        ///                 foreach(UserError error in userErrors) {
        ///                     // field which may have a user error
        ///                     Debug.Log(error.field());
        ///                     // error message for the field which had an error
        ///                     Debug.Log(error.message());
        ///                 }
        ///             } else {
        ///                 Debug.Log("No user errors the customer was created");
        ///             }
        ///         }
        ///     }
        /// );
        /// \endcode
        public void Mutation(MutationDelegate buildQuery, MutationRootHandler callback)
        {
            MutationQuery query = new MutationQuery();

            buildQuery(query);

            Mutation(query, callback);
        }
Esempio n. 2
0
 /// <summary>
 /// Allows you to send custom prebuilt GraphQL mutation queries to the Storefront API.
 /// </summary>
 /// <param name="query">a query to be sent to the Storefront API</param>
 /// <param name="callback">callback which will receive a response</param>
 /// \code
 /// // Example that creates a custom mutation query
 /// MutationQuery mutation = new MutationQuery();
 ///
 /// mutation.customerCreate(
 ///     buildQuery: (cc) => { cc
 ///         .userErrors(
 ///             buildQuery: (ue) => { ue
 ///                 .field()
 ///                 .message();
 ///             }
 ///         );
 ///     },
 ///     input: new CustomerCreateInput(
 ///         email: "*****@*****.**",
 ///         password: "******"
 ///     )
 /// );
 ///
 /// ShopifyBuy.Client().Mutation(
 ///     query: mutation,
 ///     callback: (data, error) => {
 ///         if (error != null) {
 ///             Debug.Log("There was an error: " + error.Reason);
 ///         } else {
 ///             List<UserError> userErrors = data.customerCreate().userErrors();
 ///
 ///             if (userErrors != null) {
 ///                 foreach(UserError error in userErrors) {
 ///                     // field which may have a user error
 ///                     Debug.Log(error.field());
 ///                     // error message for the field which had an error
 ///                     Debug.Log(error.message());
 ///                 }
 ///             } else {
 ///                 Debug.Log("No user errors the customer was created");
 ///             }
 ///         }
 ///     }
 /// );
 /// \endcode
 public void Mutation(MutationQuery query, MutationRootHandler callback)
 {
     Loader.Mutation(query, (response) => {
         callback(response.data, (ShopifyError)response);
     });
 }