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

Concern about loss of deprecated GraphService.PostAsync methods #1142

Open
judoscott opened this issue Jan 22, 2025 · 7 comments
Open

Concern about loss of deprecated GraphService.PostAsync methods #1142

judoscott opened this issue Jan 22, 2025 · 7 comments
Labels
deprecated class or method Deals with a class or method in ShopifySharp that is, should, or will be deprecated. question

Comments

@judoscott
Copy link

[Obsolete("This method is deprecated and will be removed in a future version of ShopifySharp.")] public virtual async Task<JToken> PostAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default)

We were unable to migrate to the latest version of this library because of this issue: #1080

Now that its resolved in prerelease I have upgraded a branch and see that the above method is deprecated. Please consider keeping it we have a lot of stuff built on it. If you can't do that please keep it for a significant time to allow time for our migration while using current packages,

Thanks for all the great work

@nozzlegear nozzlegear added question deprecated class or method Deals with a class or method in ShopifySharp that is, should, or will be deprecated. labels Jan 22, 2025
@nozzlegear
Copy link
Owner

Hey @judoscott, thanks for reaching out about this! I understand your concern about losing the method you rely on. In the long term, I do still plan on removing it, but I can promise you that they'll remain available in the latest versions of ShopifySharp for at least the next 60 days. I try to do my best to give everyone plenty of time to migrate off of methods or classes that have been deprecated, so I don't want to pull the rug out and remove things as quickly as possible.

It looks like I forgot to include it in that obsolete message, but what I recommend everyone use now is GraphService.PostAsync(GraphRequest graphRequest) or GraphService.PostAsync<T>(GraphRequest graphRequest). The first one is the most similar to what you have right now, it'll return a disposable GraphResult object which has an IJsonElement Json property on it.

Here's the interface for IJsonElement, and at the moment the actual type implementing it is the SystemTextJsonElement. I plan on adding a NewtonsoftJsonElement soon.

Here's a link to the docs I've written on using the GraphService and the updated PostAsync(GraphRequest) methods, including the one that's closest to your current implementation. Let me know if you have any questions about it, I'm happy to help!

@judoscott
Copy link
Author

Thanks.. I did get some working examples of the the method GraphService.PostAsync(GraphRequest graphRequest) working today that you refer too.

At the moment I am hung up on at the moment is this:

Finally, depending on your IDE, you may need to install a GraphQL plugin. If necessary, configure the plugin to find the graphql.config.yml file you downloaded from this repository. Once you've got the plugin installed and configured, you should find that you now have full intellisense and autocomplete for all of your Shopify GraphQL queries/mutations written with ShopifySharp.

I use Visual Studio 2022 and I am not familiar with how yml files are processed for this. I do get the concept just no experience using it. So currently in a research mode to see how to implement it with my set up. If you have any examples or links I would be very grateful.

@nozzlegear
Copy link
Owner

Ah unfortunately I'm on a Mac so I'm not familiar with how Visual Studio's GraphQL plugin works myself, I was hoping the setup would be simple! 😅 The file should physically go at the root of your project, as the path inside the yml file needs to point to the other graphql.schema.json file you downloaded.

I'm not positive, but it might help to include the yml file in your solution too (right click, add existing item to solution). That might help the plugin find it.

@judoscott
Copy link
Author

gotcha

I did try using classes we already have from https://github.com/Husqvik/GraphQlClientGenerator/

But haven't gotten it to work. object returns but all values are null

@nozzlegear
Copy link
Owner

Hmm, could you post some example code I could take a look at?

@nozzlegear
Copy link
Owner

Hey @judoscott, just wanted to check in – did you manage to get those classes working?

@judoscott
Copy link
Author

@nozzlegear I determined my issue it because my generated classes can handle System.Text.Json or Newtonsoft but not a project with both. I wrote a class that inherits GraphService and takes the new GraphRequest object but outputs JToken so that I could keep on moving to make my deadlines. Will go back and make something more efficient later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated class or method Deals with a class or method in ShopifySharp that is, should, or will be deprecated. question
Projects
None yet
Development

No branches or pull requests

2 participants