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

Expose Content Fields Indexing via GraphQL for content field filtering #16092

Open
wants to merge 60 commits into
base: main
Choose a base branch
from

Conversation

mdameer
Copy link

@mdameer mdameer commented May 17, 2024

Fix #12781

image

Enhancements:

  1. Expose Content Fields Indexing via GraphQL for content field filtering
  2. Add more content definition events for updated types, parts, and fields

Known Issues:

  1. MultiTextField which is defined as ListGraphType<StringGraphType> will not be filterable due to that ListGraphType is not derived from ScalarGraphType, and when I tried to fix it by extracting the generic type and using it to expose the field, I found that it will not work as expected
  2. Filtering on DateTimeGraphType is not working properly with the SQLite database, I don't think that it is related to this PR, more investigation is needed before determining if a new issue should be opened.

Copy link

Thank you for submitting your first pull request, awesome! 🚀 If you haven't already, please take a moment to review our contribution guide. This guide provides helpful information to ensure your contribution aligns with our standards. A core team member will review your pull request.

If you like Orchard Core, please star our repo and join our community channels

@hishamco
Copy link
Member

@hyzx86 could you please review this?

@hyzx86
Copy link
Contributor

hyzx86 commented May 18, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 18, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented May 18, 2024

Walkthrough

The recent updates introduce the ability to filter content fields via GraphQL by leveraging content fields indexing. This enhancement includes new classes, methods, and event handlers to support dynamic content fields indexing and querying in GraphQL. The changes span multiple files, adding new functionalities and modifying existing ones to facilitate this feature.

Changes

Files/Paths Change Summary
src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ContentFieldsProvider.cs Added imports, new properties, classes, and methods for field indexing in GraphQL.
src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Fields/ObjectGraphTypeFieldProvider.cs Added imports, reformatted code, and implemented methods for field indexing.
src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Startup.cs Added IndexStartup class to configure services for GraphQL content fields input.
src/OrchardCore.Modules/OrchardCore.ContentTypes/Services/ContentDefinitionService.cs Added event handler invocations for content part and field updates.
src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/Types/TimeSpanGraphType.cs Changed namespace to OrchardCore.Apis.GraphQL.Queries.Types.
src/OrchardCore/OrchardCore.Apis.GraphQL.Abstractions/Queries/WhereInputObjectGraphType.cs Added imports and modified method to include checks for various graph types.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Options/GraphQLContentOptions.cs Modified GetFieldName method to return fieldName.ToCamelCase().
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/OrchardCore.ContentManagement.GraphQL.csproj Added project reference to OrchardCore.ContentTypes.Abstractions.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/ContentItemWhereInput.cs Added imports, changed method accessibility, and added method overloads.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentFieldsIndexAliasProvider.cs Added new class for generating index aliases for dynamic content fields in GraphQL queries.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentTypeBuilder.cs Added new class and modified methods to include logic for dynamic content type building.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicPartInputGraphType.cs Added new class to dynamically generate input fields based on content part definitions.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/IContentFieldProvider.cs Added imports and methods for field indexing.
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/ServiceCollectionExtensions.cs Added method to register services related to dynamic content fields input for GraphQL.
src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentFieldUpdatedContext.cs Added new class extending ContentPartFieldContext.
src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentPartFieldUpdatedContext.cs Added new class extending ContentPartFieldContext.
src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentPartUpdatedContext.cs Added new class extending ContentPartContext.
src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentTypePartUpdatedContext.cs Added new class extending ContentTypePartContext.
src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/ContentTypeUpdatedContext.cs Added new class extending ContentTypeContext.
src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Events/IContentDefinitionEventHandler.cs Added new methods for handling content type, part, and field updates.

Assessment against linked issues

Objective Addressed Explanation
Expose Content Fields Indexing via GraphQL for content field filtering (#12781)
Provide built-in way to filter on content field values from GraphQL (#12781)
Leverage existing Content Fields Indexing for SQL queries in GraphQL (#12781)

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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: 3

Out of diff range and nitpick comments (1)
src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Types/DynamicContentTypeBuilder.cs (1)

Line range hint 15-159: Refactor to improve readability and reduce complexity in the method Build.

- public void Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType)
+ public void Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType)
{
    // Refactor complex logic into smaller, more manageable methods.
}

Copy link
Contributor

@hyzx86 hyzx86 left a comment

Choose a reason for hiding this comment

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

Thanks for contributing, have some minor questions for reference :)

You can include screenshots of the feature in the PR description, and then please update the documentation when the PR feature is finalized https://github.com/OrchardCMS/OrchardCore/blob/main/src/docs/releases/2.0.0.md

@hishamco
Copy link
Member

Thanks @hyzx86, and please @mdameer react to Tony's feedback

@hishamco
Copy link
Member

@mdameer please request a review from Tony once you done

@Piedone
Copy link
Member

Piedone commented May 18, 2024

@hyzx86
Copy link
Contributor

hyzx86 commented May 19, 2024

Please document this under https://docs.orchardcore.net/en/latest/reference/modules/SQLIndexing/#content-fields-indexing.

It doesn't look like additional indexes have been added, this PR is just an enhancement to the graphql filtering functionality

@hyzx86
Copy link
Contributor

hyzx86 commented May 19, 2024

Screenshot of my test using the blog recipe,looks like there are some issues that need to be addressed 😳
image

@hyzx86
Copy link
Contributor

hyzx86 commented May 19, 2024

Please do not close the conversation posed by the reviewer, as this will collapse subsequent comments.
For example #16092 (comment)
you can comment Done directly afterwards to mark the issue as resolved!

@hyzx86
Copy link
Contributor

hyzx86 commented May 19, 2024

Hi @mdameer ,Before we continue, perhaps we can discuss this improvement here
#16008

Personally, I think that adding all the fields directly as they are now would result in a schema structure that is too large and would look like too many fields in the schema viewer That's just my opinion,
@hishamco @Piedone , and I'd like to know what you think about that : )

@hishamco
Copy link
Member

We can discuss this IMHO as @hyzx86 suggested

@Piedone
Copy link
Member

Piedone commented May 19, 2024

It doesn't look like additional indexes have been added, this PR is just an enhancement to the graphql filtering functionality

That such indexes are available via GraphQL is a new thing, and that needs to be documented.

@Piedone
Copy link
Member

Piedone commented May 19, 2024

Personally, I think that adding all the fields directly as they are now would result in a schema structure that is too large and would look like too many fields in the schema viewer That's just my opinion, @hishamco @Piedone , and I'd like to know what you think about that : )

Do you mean this?

image

I think this is fine, we have a search feature there for a reason.

@hyzx86

This comment was marked as off-topic.

@hyzx86
Copy link
Contributor

hyzx86 commented May 20, 2024

What I mean is that I would like to replace these with enumerations such as in ,not_in ,contains and in, not_in, contains and in.

OK, leaving that aside for now, this PR is good enough, let's discuss these in subsequent improvements。

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.

LGTM, it's a very good feature. Thanks a lot.

Copy link

github-actions bot commented Jun 7, 2024

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

@hishamco
Copy link
Member

hishamco commented Jun 7, 2024

While there are a few changes in GraphQL recently @hyzx86 anything to add here, we need to merge this ASAP

Copy link
Contributor

@hyzx86 hyzx86 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@hishamco
Copy link
Member

hishamco commented Jun 7, 2024

@mdameer please merge the conflict then we will merge, I think both @hyzx86 & @gvkries are fine with these changes, right?

@mdameer
Copy link
Author

mdameer commented Jun 7, 2024

@mdameer please merge the conflict then we will merge, I think both @hyzx86 & @gvkries are fine with these changes, right?

I’m on it, but it will take some time to test the latest changes on the main branch.

@mdameer
Copy link
Author

mdameer commented Jun 8, 2024

@mdameer please merge the conflict then we will merge, I think both @hyzx86 & @gvkries are fine with these changes, right?

@hishamco Done

@mdameer mdameer requested review from gvkries and hyzx86 June 8, 2024 16:48
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.

I think in the long run it would be better if IIndexAliasProvider.GetAliases is asynchronous. This avoids using sync over async calls (GetAwaiter().GetResult()).

@mdameer mdameer requested a review from gvkries June 10, 2024 20:55
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.

Great work, thanks a lot.

@mdameer
Copy link
Author

mdameer commented Jun 12, 2024

@hishamco I believe this pull request is ready to be merged. Please let me know if any further changes are needed.

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.

Expose Content Fields Indexing via GraphQL for content field filtering
5 participants