Exemplo n.º 1
0
        public void CanMutationHandleLoadErrors()
        {
            MutationResponse response    = null;
            QueryLoader      queryLoader = new QueryLoader(new TestLoader());

            queryLoader.Mutation(TestQueries.MutationFail, (MutationResponse r) => {
                response = r;
            });

            Assert.IsNull(response.data);
            Assert.IsNull(response.errors);
            Assert.AreEqual("Error: 404 Not Found error", response.HTTPError);
        }
Exemplo n.º 2
0
        public void CanMutate()
        {
            MutationResponse response    = null;
            QueryLoader      queryLoader = new QueryLoader(new TestLoader());

            queryLoader.Mutation(TestQueries.Mutation, (MutationResponse r) => {
                response = r;
            });

            Assert.IsNull(response.errors);
            Assert.IsNull(response.HTTPError);
            Assert.IsNotNull(response.data);
            Assert.AreEqual("12345", response.data.customerAccessTokenCreate().customerAccessToken().accessToken());
        }
Exemplo n.º 3
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);
     });
 }