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

Add GraphQL support to UserPickerField #15389

Merged
merged 27 commits into from
Apr 24, 2024
Merged

Conversation

hyzx86
Copy link
Contributor

@hyzx86 hyzx86 commented Feb 22, 2024

image

@hyzx86 hyzx86 changed the title Add UserPickerField GraphQL Type Add Graphql support to UserPickerField and support CustomUserSettings Feb 22, 2024
@@ -10,6 +10,6 @@ public class Startup : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ISchemaBuilder, CurrentUserQuery>();
services.AddTransient<UserType>();
services.AddSingleton<UserType>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gvkries , Do you have any other suggestions on how to reuse this type, which would cause an error if you used Transient lifetime?

Could you help to Review this PR? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UserType is currently only populated by the CurrentUserQuery schema builder. It is not individually registered as a type in GraphQL, so I guess that has to change. I need to think about this...

@hyzx86
Copy link
Contributor Author

hyzx86 commented Feb 22, 2024

@hishamco Could you help to review this PR? Thanks!

@hyzx86 hyzx86 marked this pull request as draft February 22, 2024 07:04
@hyzx86
Copy link
Contributor Author

hyzx86 commented Feb 22, 2024

Not ready, Not ready, now the type updates will cause an error

@hishamco
Copy link
Member

We will check once it's ready

@hyzx86
Copy link
Contributor Author

hyzx86 commented Feb 22, 2024

Now I have a sequence-dependent problem. When I implement UserPickerFieldGrpahType in ContentFields Module , dynamic fields cannot be used because the CustomUserSettings in UserType has not been initialized.

However, if I migrate UserPickerField into the User module, I will also need to migrate all other resources for that field, such as some view files , DispayDrivers and It also includes migration of some data structures, such as UserPickerFieldIndex

@hyzx86
Copy link
Contributor Author

hyzx86 commented Feb 22, 2024

I updated the 'me' field with the ContentItemInterface

Everything seems normal so far

image

@hyzx86 hyzx86 marked this pull request as ready for review February 22, 2024 17:40
@hyzx86 hyzx86 requested a review from gvkries February 22, 2024 17:41
@@ -10,6 +10,6 @@ public class Startup : StartupBase
public override void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ISchemaBuilder, CurrentUserQuery>();
services.AddTransient<UserType>();
services.AddScoped<UserType>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you get the right instance of the UserType in any circumstances? I think we should change the way the UserType is build, what I did within the CurrentUserQuery seems not enough anymore.

Copy link
Contributor Author

@hyzx86 hyzx86 Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they have the same hash code
image

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 9, 2024

Hi @gvkries , do you have any other suggestions?

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 14, 2024

Hi @Skrypt , Can you help to review this PR?

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 18, 2024

fixed: #15540

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 18, 2024

@MikeAlhayek And this PR 🫡

@gvkries
Copy link
Contributor

gvkries commented Mar 19, 2024

Hi @gvkries , do you have any other suggestions?

Sorry, I didn't have time for this. I take a look as soon as possible.

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 19, 2024

Hi @hishamco , This PR is ready for review.

@Piedone
Copy link
Member

Piedone commented Apr 22, 2024

I see. What confused me is that that PR is supposed to fix #15540 (as indicated in its description), just as this one (as indicated in the issue).

@gvkries
Copy link
Contributor

gvkries commented Apr 22, 2024

I see. What confused me is that that PR is supposed to fix #15540 (as indicated in its description), just as this one (as indicated in the issue).

Yes, that bug is fixed by both PRs, but this is more about the additional feature 🤗

@Piedone
Copy link
Member

Piedone commented Apr 22, 2024

OK, thanks. I'll review this once #15691 is merged, then.

Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

@hishamco
Copy link
Member

OK, thanks. I'll review this once #15691 is merged, then.

It's merged

@Piedone
Copy link
Member

Piedone commented Apr 22, 2024

Thanks! @hyzx86 please fix the merge conflict and let me know.

Name = nameof(UserPickerField);

Field<ListGraphType<StringGraphType>, IEnumerable<string>>("userIds")
.Description("user ids")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all descriptions should be localizable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When addressing review feedback, please adhere to the following:

  • Please update your pull request according to feedback until it is approved by one of the core team members.
  • Apply suggested changes directly so the reviewer doesn't have to eyeball the changes. These resolve themselves after applying them, and that's fine.
  • Don't resolve other conversations so it's easier to track for the reviewer. Then, the reviewer will resolve them.
  • Feel free to mark conversations that you addressed to keep track of them with an emoji or otherwise, just don't resolve them.
  • Please keep conversations happening in line comments in those convos, otherwise, communication will be a mess. If you have trouble finding them, see this video.
  • When you're done addressing all feedback of a review, click "Re-request review" in the top-right corner for each reviewer when you're ready for another round of review, so they know that you're done.

hyzx86 and others added 2 commits April 24, 2024 16:49
…s/UserPickerFieldQueryObjectType.cs

Co-authored-by: Zoltán Lehóczky <[email protected]>
…s/UserPickerFieldQueryObjectType.cs

Co-authored-by: Zoltán Lehóczky <[email protected]>
Copy link
Contributor

coderabbitai bot commented Apr 24, 2024

Walkthrough

Walkthrough

The recent update enriches the GraphQL module in OrchardCore by incorporating user picker capabilities. This enhancement enables seamless querying of user picker fields through specific GraphQL query types. Users can now retrieve user-related data such as user IDs and user items efficiently. Additionally, the update includes a project reference to OrchardCore.Users for streamlined dependency management.

Changes

File Path Change Summary
.../GraphQL/Startup.cs
.../GraphQL/Types/UserPickerFieldQueryObjectType.cs
Added registration for UserPickerField and UserPickerFieldQueryObjectType. Introduced UserPickerFieldQueryObjectType for querying user picker fields in GraphQL.
.../OrchardCore.ContentFields.csproj Added ProjectReference to OrchardCore.Users.csproj.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3d6a459 and 5e360be.
Files selected for processing (1)
  • src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/UserPickerFieldQueryObjectType.cs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/UserPickerFieldQueryObjectType.cs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Out of diff range and nitpick comments (1)
src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/UserPickerFieldQueryObjectType.cs (1)

25-25: Consider making the description localizable to support multiple languages.

@hyzx86 hyzx86 requested review from Piedone and gvkries April 24, 2024 09:49
Copy link
Contributor

@gvkries gvkries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside what @Piedone said, LGTM. Whether we want to keep the firstUser field or not is up to you guys, I'm fine with either decission.

hyzx86 and others added 2 commits April 25, 2024 00:47
Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@Piedone Piedone merged commit 08a6771 into OrchardCMS:main Apr 24, 2024
5 checks passed
@Piedone Piedone changed the title Add Graphql support to UserPickerField and support CustomUserSettings Add GraphQL support to UserPickerField Apr 24, 2024
@hyzx86 hyzx86 deleted the UserPickerField branch June 13, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants