Skip to content

Documentation: write a guide on how to use ShopifySharp with the GraphQL API #1099

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

Closed
nozzlegear opened this issue Oct 1, 2024 · 18 comments · Fixed by #1126
Closed

Documentation: write a guide on how to use ShopifySharp with the GraphQL API #1099

nozzlegear opened this issue Oct 1, 2024 · 18 comments · Fixed by #1126

Comments

@nozzlegear
Copy link
Owner

Shopify has announced¹ that after April 2025, all new public apps submitted to the Shopify app store must use GraphQL, and the REST API will be deprecated. ShopifySharp does support the GraphQL API, but the documentation is extremely lacking. I'm updating the documentation for this right now, and will write a longer guide on building an app with ShopifySharp + GraphQL as well.

¹ https://shopify.dev/changelog/starting-april-2025-new-public-apps-submitted-to-shopify-app-store-must-use-graphql

@ThatBrianK
Copy link

Hi,
I'm looking forward to this documentation. I'm a little unclear on the direction things will be going in this development overall. Will we be able to use the existing ShopifySharp.Product and ProductService objects that will use an underlying GraphQL API call in the future? or will those be deprecated once we hit 2025-04 and we'll have to use the GraphQL objects directly?

@nozzlegear
Copy link
Owner Author

Hey @ThatBrianK! I'm planning to support the Rest API, and therefore the ProductService, for as long as Shopify themselves support it. New apps won't be able to use the Rest API after April 2025, and if I had to bet, I'd put my money on the Rest API being removed completely in April 2026 for existing apps.

I don't plan on deprecating ShopifySharp itself at any point though, since I still use it every day for my own Shopify apps and for my clients' apps. We'll have the same GraphService that we have right now, where you can write completely custom queries specialized for exactly the data that you need; and then perhaps (speculation here, I haven't finalized my plans) individual services like we have today such as a ProductService that just makes Graph API calls instead of Rest API calls.

@ThatBrianK
Copy link

Thanks for the update. I really feel the 6 month deadline looming ( I need to be able to support new clients), and I'm completely new to graphQL. I am going to try and document as best I can my process of converting my existing product/variant sync with the existing ProductService and ProductVariantService to queries written for graphQL, so that maybe it can be helpful to others in my situation. It's too bad it's so different, as the primary reason for me using ShopifySharp was how easy it made working with products and variants as all the fine details were taken care of.
Thanks again for all your work on this project and hopefully I can make my own contribution eventually!0

@jbyte2009
Copy link

Yes. This would be great.

@contech-ernst-meinhart
Copy link

contech-ernst-meinhart commented Jan 2, 2025

@nozzlegear finalization of your plans regarding this would be very appreciated.
As for my case i currently build a new shopify integration and only by coincidence when researching for other issues i found this topic here. I´ve assumed that this integration is using the GraphQL anyway out of the box and started implementing.

Now i know, that i should better use the GraphQL service as i don´t want to change the integration anytime soon. In my opinion this topic should be noticable highlighted in README when visiting the this repo to avoid probably many frustration when somebody is not aware that this integration is using the REST API by default.

Also as on Shopify docs the deprecation of REST API is so present that i would never think that any maintained Sdk would still use this Api anymore.

@nozzlegear
Copy link
Owner Author

Hey @contech-ernst-meinhart, thanks for bringing this up! I've been actively working on #1051 for the last month or so, which has been my main blocker for moving forward with any other GraphQL improvements, including documentation; I wanted to start off with a solid foundation.

That said, over the last couple days I've been actively cleaning up the commits in that PR and splitting them into smaller PRs. It will be merged today, along with documentation on how to use the GraphService.

After that, I'm going to begin writing a more in-depth guide on using Shopify's GraphQL API with the GraphService. It'll probably be something along the lines of "how to create, update and manage products using ShopifySharp and Shopify's GraphQL API" since that's a popular topic.

Following that, I have two plans:

  1. Begin implementing Feature: Generate methods based on .graphql files #1072
  2. Explore repurposing the various REST API services (e.g. ProductService, OrderService) and filling them out with Shopify's GraphQL queries and mutations. So instead of ProductService.ListAsync and ProductService.UpdateAsync using the REST API endpoints, it might use the GraphQL products(first: ...) { ... } query and productUpdate(product: ...) { } mutation.

Let me know what you think!

@nozzlegear
Copy link
Owner Author

Also as on Shopify docs the deprecation of REST API is so present that i would never think that any maintained Sdk would still use this Api anymore.

I missed this part. The situation has been a bit confusing, but the REST API is still "allowed" for any app that's already been approved and published on the app store, and for any custom app that was created before a certain date. That's why ShopifySharp still supports the REST API: Shopify has certainly deprecated it, but it's not dead yet and existing apps can still use it for at least another six months.

You're right about the documentation though; the fact that new apps must use the GraphService really needs to be called out.

@clement911
Copy link
Collaborator

Hi @nozzlegear

I understand that you have been working on some significant changes in a separate branch.
That's great. I love that you keep investing in the project.

I haven't had a look into the specific changes yet.
That being said, I wanted to chime in regarding the potential scope creep of the project.
I personally believe that we should keep a very simple and thin core.

I understand that you are exploring generating method based on .graphql files and also 'repurposing the various REST API services and filling them out with Shopify's GraphQL queries and mutations'.

Are you planning on creating separate nuget packages for those?

I'm not sure that hard coding graphql queries in the project is a good idea. They have been quite aggressive in deprecating fields and changing the API. Hard coding queries might cause some maintenance headaches down the line.

@nozzlegear
Copy link
Owner Author

Thanks @clement911! I'm wary of scope creep too — I've built up a list of interesting ideas that I've wanted to explore while working with clients over the last year, and a lot of it revolves around dev tooling in this space. I'm going to try to be careful not to bloat the base ShopifySharp package itself with stuff that doesn't belong.

I think secondary Nuget packages will be the best fit for some of the stuff I've been talking about for sure. For #1072 in particular, I don't see that being included in ShopifySharp itself but rather something like "ShopifySharp.Graph.Generator" (just off the top of my head). I could also see the hardcoded queries/mutations services going into its own Nuget package as well, since it'd be likely to get frequent updates as you said. In that scenario, ShopifySharp could continue along at its somewhat slower release cadence, with the base GraphService and the generated GraphQL classes.

As always, I'm open to feedback on this stuff! I'll open up an issue for more discussion on those two packages I talked about soon.

@nozzlegear nozzlegear moved this from Todo to In Progress in ShopifySharp GraphQL improvements Jan 3, 2025
@nozzlegear nozzlegear pinned this issue Jan 3, 2025
@nozzlegear nozzlegear linked a pull request Jan 7, 2025 that will close this issue
9 tasks
@nozzlegear nozzlegear added this to the 6.23.0 milestone Jan 15, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in ShopifySharp GraphQL improvements Jan 21, 2025
@nozzlegear
Copy link
Owner Author

I've just released documentation for using ShopifySharp's updated GraphService over on the wiki. Let me know if it needs more information or if anything's unclear!

@DeFlight
Copy link

SO, I have been trying to implement this with no success. I am using Visual Studio 2022. However, I am not able to get the yml. and json to be read within VS. Also, i downloaded the "GraphQLTools" extension. That does not seem to work either. Am I missing something to allow for the graph QL to show the correct colors and also provide intellisense?

What am I missing here

Image

@nozzlegear
Copy link
Owner Author

Hey @DeFlight! I'm not entirely sure what the issue might be there. I'm on a Mac so I don't have any first-hand experience with using the Visual Studio plugin, I just know that it should work the way it's described.

I'd check the following:

  1. Make sure the two graphql config files are at the root of your solution folder.
  2. Try including those files in your solution and see if that helps VS "find" them. Unload and reload your project when you do this.
  3. Check the target framework versions for your projects. I believe the syntax highlighting and intellisense only works if your project is using .NET 7 or above. It won't work on .NET Framework at all from what I understand because it relies on the StringSyntaxAttribute.

@DeFlight
Copy link

So I am targeting 9.0.

I have them in the folder where the .sln file is. When you say include, I’m not sure what you mean exactly? Do you mean copy to compiled? Any light to shed on this let me know. The colors I don’t care really about but the fact the intellisense does not work is the real issue for me.

On a side note, I notice, for example Queeying orders it shows all the orders properties as “null” when not being used as a node. This is when using the pre defined object for “orders”. Is there a way to only have it bring in what is asked for from the query? Not sure I am making sense.

@foxandrewj
Copy link
Contributor

foxandrewj commented Feb 28, 2025

@DeFlight Have you had any luck yet?
I just tried setting this up today and I can't get the feature to work either.
VS 2022 Community on Windows with GraphQLTools Extension installed.
.NET 8.0 Framework project
I added the yml and json to the project root, restarted, rebooted. Doesn't seem to work.

@nozzlegear
Copy link
Owner Author

nozzlegear commented Feb 28, 2025

Woops, I forgot about this, sorry everyone! My wife has a Windows machine, I'll see if I can borrow it this weekend and try to debug why it's not working in Visual Studio. For reference, I'm using .NET's StringSyntaxAttribute to hint to the IDE/LSP that any string in GraphRequest.Query should use GraphQL syntax highlighting.

Here are some of the reference links I used when developing the feature:

It seems that the Visual Studio plugin supports syntax highlighting, but not intellisense, which is odd. I'll let you guys know what I figure out when I have a chance to debug the issue this weekend.

@DeFlight
Copy link

It’s all good. Yea same issue persists. No clue what it could be to be honest. I have had to manually enter every node and every edges etc. hopefully we can figure it out .).Eitherway Shopify sharp is amazing.

@abeninski
Copy link

I have the same issue on Windows, VS 2022

@mcash95
Copy link

mcash95 commented May 20, 2025

Any updates on this? Running into the same issues, curious if anyone has found a solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

9 participants