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

Problem building against WPGrapQL #92

Open
richardaubin opened this issue Feb 5, 2024 · 11 comments
Open

Problem building against WPGrapQL #92

richardaubin opened this issue Feb 5, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@richardaubin
Copy link

Describe the bug

This appears to be an issue similar or the same I had with StrawberryShake against the same schema source.

How to Reproduce
Create a Wordpress website: download free app https://localwp.com/ to create a local wordpress installation.

Install the WPGraphQL plugin: https://wordpress.org/plugins/wp-graphql

Go through zeroql setup steps, and when reaching the build step, build fails with 14 errors:
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(78909,43): error CS1001: Identifier expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(78909,43): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(78910,13): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(78911,43): error CS1001: Identifier expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(78911,43): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(78912,13): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,958): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,964): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,1033): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,1039): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,1775): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,1781): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,1850): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]
f:\qlclient\obj\ZeroQL\config.zeroql.json.g.cs(83231,1856): error CS1003: Syntax error, ',' expected [f:\qlclient\qlclient.csproj]

Expected behavior

A Successful build

schema.zip

The GraphqQL schema that fails

Attached as zipfile

Screenshots

image

Environment (please complete the following information):

  • Nuget package version [6.1.1]
  • IDE:vs2022 (nut never opened)
  • .Net Version 8

Additional context
Add any other context about the problem here.

@richardaubin richardaubin added the bug Something isn't working label Feb 5, 2024
@richardaubin
Copy link
Author

richardaubin commented Feb 6, 2024

I believe this might be an issue with enums. The schema contains enums that begin with _ which are the 14 errors in the generated source code.

enum MediaItemSizeEnum {
LARGE
MEDIUM
MEDIUM_LARGE
THUMBNAIL
WOOCOMMERCE_GALLERY_THUMBNAIL
WOOCOMMERCE_SINGLE
WOOCOMMERCE_THUMBNAIL
_1536X1536
_2048X2048
}

@richardaubin
Copy link
Author

After going and manually fixing the enum errors to include the _ in the generated source, a whole bunch of other errors sprang up:

image

@richardaubin
Copy link
Author

wpgraphql.zip

This is sdl version of the schema.

@byme8
Copy link
Owner

byme8 commented Feb 6, 2024

I have fixed the issue with the enums(6.2.0-preview.3), but as you showed, it now fails with interfaces. Some fields in the schema have additional arguments compared to those defined in interfaces. I will have a look later today.

@richardaubin
Copy link
Author

I appreciate that.

@richardaubin
Copy link
Author

Hello, are you making progress?

@byme8
Copy link
Owner

byme8 commented Feb 13, 2024

I fixed the situation that was responsible for the first two issues. However, there is another issue. The schema contains the interfaces Node and Product. Then the Product is assigned to Node property. In GraphQL, it works. In C# is doesn't because the Product has to implement Node. I am thinking about how to fix it.

@byme8
Copy link
Owner

byme8 commented Feb 19, 2024

How do you get this schema? Looks like it is broken. There are interfaces that are not explicitly "implemented". For example, PageEditorBlock and EditorBlock. They are identical and have zero relations between each other on the schema level, but properties use them as if they are identical.

The same issue was with Node in lots of places. I decided to force the generation to "believe" that it is okay because it is a part of the GraphQL Relay. However, with the EditorBlock, it is not so straightforward.

@byme8
Copy link
Owner

byme8 commented Feb 19, 2024

How do you get this schema?

Nevermind. You already mentioned it in the initial description.

@richardaubin
Copy link
Author

Thanks for staying on this.

Wordpress has various 'post' types, including 'post' and 'pages' by default.

The EditorBlock interface is provided by a 3rd party plugin which adds graphql functionality for one of the core features of wordpress, the Gutenberg Block editor, which allows users to assemble their content using modules/bocks r: https://github.com/wpengine/wp-graphql-content-blocks/tree/main

This explains why the different interfaces.... They are used to determine under which contexts (post, page, etc..) they can be used. Probably to not allow them to appear on post types not supported by the Gutenberg editor and related enabled post types in the main graphql plugin.

image

@richardaubin
Copy link
Author

So though they each have the same properties, the interfaces are only being used as markers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants