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

GraphQL where clause not working for ContentItemIndex fields #3684

Closed
naammeinkyahai opened this issue May 22, 2019 · 7 comments · Fixed by #3692
Closed

GraphQL where clause not working for ContentItemIndex fields #3684

naammeinkyahai opened this issue May 22, 2019 · 7 comments · Fixed by #3692

Comments

@naammeinkyahai
Copy link

naammeinkyahai commented May 22, 2019

My GraphQL query is

{
  helpContent(where: { contentItemId: "4t4zm5yk5mvx3tmz6stsy2rrn6"}) {
    contentItemId
    displayText
    publishedUtc
  }
}

This is what the generated query looks like for postgresql(tp_ is the table prefix):

SELECT "tp_Document".* FROM "tp_Document" INNER JOIN "tp_ContentItemIndex" ON "tp_ContentItemIndex"."DocumentId" = "tp_Document"."Id" WHERE ("tp_ContentItemIndex"."Published" = $1) AND ("tp_ContentItemIndex"."ContentType" = $2) AND (("ContentItemIndex"."contentItemId" = $3)) ORDER BY "tp_ContentItemIndex"."CreatedUtc" DESC

Using orderBy clause on the same field work well so issue seems to be with where clause only.

There are two issues:

  1. Please look at the 3rd where parameter where the ContentItemIndex table doesn't have the appropriate table prefix unlike rest of the items.
  2. contentItemId retains the camelCasing instead of the PascalCased column name expected.

I tried debugging the code and my suspicion is
src\OrchardCore\OrchardCore.ContentManagement.GraphQL\Queries\ContentItemsFieldType.cs
For # 1, predicateQuery.CreateAlias("", nameof(ContentItemIndex)); seems to be the issue. We are not determining the right alias.
For # 2, I think orderBy implements a switch statement which changes the case of the fields.

@Jetski5822
Copy link
Member

@carlwoodhouse ^^^^

@carlwoodhouse
Copy link
Member

Yeah assume this is a bug with table prefixes, I can take a look this week sometime if no one else does

Jetski5822 pushed a commit that referenced this issue May 23, 2019
jdiaz87 added a commit to ReadingHorizons/OrchardCore that referenced this issue May 23, 2019
Fixes OrchardCMS#3684 - GraphQL where statements dont work for contentitemindex…
@naammeinkyahai
Copy link
Author

naammeinkyahai commented May 23, 2019

@carlwoodhouse Thank you for fix. However, that resolves only 1 of the 2 problems I reported with the query.

  1. Please look at the 3rd where parameter where the ContentItemIndex table doesn't have the appropriate table prefix unlike rest of the items.

The following problem is not resolved:

  1. contentItemId retains the camelCasing instead of the PascalCased column name expected.

Please reopen this bug as I can't seem to.

@carlwoodhouse
Copy link
Member

carlwoodhouse commented May 23, 2019 via email

@naammeinkyahai
Copy link
Author

Yes, this is the log from postgres:

ERROR: column tp_ContentItemIndex.contentItemId does not exist at character 266
HINT: Perhaps you meant to reference the column "tp_ContentItemIndex.ContentItemId".

@naammeinkyahai
Copy link
Author

The orderBy implementation in the same file ContentItemsFieldType.cs solves by putting a switch case

@carlwoodhouse
Copy link
Member

carlwoodhouse commented May 23, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants