Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order update issue with GraphQL #1108

Open
jbyte2009 opened this issue Nov 17, 2024 · 11 comments
Open

Order update issue with GraphQL #1108

jbyte2009 opened this issue Nov 17, 2024 · 11 comments
Labels
bug graphql object updating Bugs and strange behavior around updating objects, primarly related to #284

Comments

@jbyte2009
Copy link

When using mutations with variables, I am getting issues with updating orders with notes. It appears that when debugging, the application closes unexpectedly, and there is no exception to be had.

@jbyte2009
Copy link
Author

Any examples would be greatly appreciated. I will also include screenshots of programming logic.

@jbyte2009
Copy link
Author

Now here is my screenshots.

I am testing the mutation process to see if there are issues. Once successful, can duplicate to other mutations. Problem is that when executing the process, when it execute the GraphService.SendAsync(...), the processor stops and abnormally terminates with no errors that mean a thing.

Here is my UpdateOrderGQL mutation. I grab all the text.

UpdateOrderGQL_Template

This is my class that collects data. Once an object is instantiated and later serialized.

ShopifyGqlUpdateOrder_Class

My manager class starts the process..

This fills in the appropriate object properties and sends the object to the Order Processor class.

ShopifyProcManager_TestUpdateOrder

The order GQL Processor get the template into a string value and passes it to the GraphQL Processor to be processed.

OrderGQLProcessor_UpdateOrder

This is where I use ShopifySharp's graphQL service and sends the update order GQL to be processed.

GrapchQLProcessor_Send

My first question is should I use the SendAsync when doing mutations?

@jbyte2009
Copy link
Author

jbyte2009 commented Nov 17, 2024

I notice you use the JSON Serializer to create the JSON object. It has been commented, but when needed provides the following JSON string:

UpdateOrderJSON

This did not work due to the Serialization that was used. - JB 11/19/2024

@jbyte2009
Copy link
Author

Thanks for your assistance.

@jbyte2009
Copy link
Author

I was able to get my mutation to work using Postman.

Here is the Request Headers.

Postman_0002

Here is the body Request. Using NewtonSoft JSON Serializer works better. The variables are in the case that works.

Postman_0001

When clicking the Send button it works.

Postman_0003

@jbyte2009
Copy link
Author

with this being stated, I believe the following changes for Shopify mutations:

The Graph Service would use the following:

I propose the following in light blue below.

GraphService

Use Newtonsoft.Json.JsonConvert.SerializeObject instead of System.Text.Json.JsonSerializer.Serialize.
This will result in the following JSON to be created. The Newtonsoft.JSON.JsonProperty (see ShopifyGqlUpdateOrder class above) will be the values used when Serializing. If you use System.Text.Json.JsonSerializer, the actual property names will be used. And will error out due to the GraphQL not matching.

UpdateOrderJSON2

Thoughts?

@nozzlegear
Copy link
Owner

Sorry, I missed this and I'm just catching up now. I'm working on ShopifySharp this afternoon, I'll review your info and update soon!

@nozzlegear
Copy link
Owner

nozzlegear commented Nov 20, 2024

@jbyte2009 Okay, sorry for the delay! Thanks for digging in, and double-thanks for all of the screenshots. To answer your question, there's a method named PostAsync which is the "official" one that I'm standardizing in #1051. It accepts an object named GraphRequest that will let you configure both the query and the query's variables. The rest of the service's methods have/were all added a bit haphazardly while we were trying to work out the best way to support GraphQL in ShopifySharp, but they'll all be deprecated once I merge and publish #1051.

Regarding the serializer, I believe that's fixed in the branch I'm working on, but I will double check and make sure it gets some unit tests added before I merge the work into the main branch.

@nozzlegear nozzlegear added bug graphql object updating Bugs and strange behavior around updating objects, primarly related to #284 labels Nov 20, 2024
@jbyte2009
Copy link
Author

When do you expect to have this change in NuGet?

I am currently on ShopifySharp 6.19.0.

VS2022_NuGet

Thanks for helping me out the company I work for. I am trying to get a head start on this new adjustment in the Shopify Admin process. Thanks.

@jbyte2009
Copy link
Author

*** Work Around *** for NuGet Package 6.19.0

Add "JsonPropertyName" attribute to each property.

ShopifyGqlUpdateOrder_Class_REVISED

Order Processor revision

OrderGQLProcessor_UpdateOrder_REVISION

Then, use Shopify Sharp's Send and you will receive no error and abnormally terminates the program

GraphQLProcessor_REVISION

@nozzlegear
Copy link
Owner

Awesome, thanks for the workaround!

When do you expect to have this change in NuGet?

I'm actively working on finishing up my pull request and getting it merged in/published, it's my main priority right now. I want to have it published by the end of the week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug graphql object updating Bugs and strange behavior around updating objects, primarly related to #284
Projects
None yet
Development

No branches or pull requests

2 participants