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

ShopifySharp.GraphQL missing. (.NET Framework 4.8 project) #1167

Open
trint99 opened this issue Mar 18, 2025 · 9 comments
Open

ShopifySharp.GraphQL missing. (.NET Framework 4.8 project) #1167

trint99 opened this issue Mar 18, 2025 · 9 comments
Labels
dnf Issues that affect .NET Framework specifically. question

Comments

@trint99
Copy link

trint99 commented Mar 18, 2025

My project is mired in .NET Framework 4.8 with no prospect of migrating soon.

I have ShopifySharp 6.22.2 installed.

The code samples from the wiki don't work. I can translate most of them, but the missing library has me stumped.

Image

How do I access the new GraphQL library?

@D3bo
Copy link

D3bo commented Mar 19, 2025

Same with .net core 3.1

@lanthonyneville
Copy link

lanthonyneville commented Mar 20, 2025

Also looking for this as my integration is .NET Framework. The short answer seems to be that all the classes in the ShopifySharp.GraphQL namespace are only included in the ShopifySharp nuget targeting .NET 6 or higher. This is controlled in the source code here:

Image

@clement911 or @nozzlegear may be able to explain why.

@lanthonyneville
Copy link

On further digging the answer to why the classes in the ShopifySharp.GraphQL namespace are not available for .NET Framework is because the code makes heavy use of "default interface members", which are not supported in .NET Framework.

What I am doing is copying the classes I need out of the source code (e.g. Product, ProductOption etc) plus their dependencies (GraphQLObject etc) into my own project, and adapting it to build under .NET Framework (e.g. removing default interface members from interfaces, and adding concrete implementations in the classes to satisfy the interfaces). Then these classes in theory can be used with the GraphService PostAsync method.

@nozzlegear
Copy link
Owner

Yes, you've got that correct @lanthonyneville. Unfortunately they're not available in .NET < 6 right now because of the default interfaces. I am actively looking into making them available in .NET Framework/Standard, I just don't have an ETA for it as it may tie into my source generator strategy for #1137.

@nozzlegear nozzlegear added question dnf Issues that affect .NET Framework specifically. labels Mar 20, 2025
@nozzlegear
Copy link
Owner

#1143 contains more info about why they don't currently work in .NET Framework right now, but you've summarized it pretty succinctly: the current implementation uses default interface methods and other .NET >= 6 features that just don't work in .NET Framework.

@trint99
Copy link
Author

trint99 commented Mar 20, 2025

Thanks @nozzlegear . For now, I have rewritten my .NET Framework code that used the ProductService and ProductVariantService to instead make direct GraphQL calls to Shopify. It's an ugly fix, but I should have it working soon. I look forward to using your new services once they're finished.

@devtest444555
Copy link

@nozzlegear I'm getting the same issue as @trint99 in my .net 6.0 project despite the #if NET6_0_OR_GREATER directive. Is this expected behavior?

@nozzlegear
Copy link
Owner

@devtest444555 Hey! That's not expected behavior, it should work in a .NET 6 project. Are you on the latest version of ShopifySharp? And if possible, can you try upgrading to .NET 8? I believe .NET 6 is no longer supported by Microsoft, and the upgrade to .NET 8 is pretty painless if I remember correctly.

@devtest444555
Copy link

@nozzlegear Hi! I'm currently using the latest (6.22.2), and interestingly, I just found an issue experiencing that same strange behavior: Here

Thanks, I think you're right. Upgrading to .NET 8.0 would be the way to go.

And sorry, I'm rather new to GraphQL, but how did you generate the GraphQLSchema.generated.cs ? Can the method you used to do that be used for other GraphQL APIs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dnf Issues that affect .NET Framework specifically. question
Projects
None yet
Development

No branches or pull requests

5 participants