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 query on Edge #1913

Closed
craighicks13 opened this issue Aug 29, 2024 · 1 comment
Closed

GraphQL query on Edge #1913

craighicks13 opened this issue Aug 29, 2024 · 1 comment
Labels

Comments

@craighicks13
Copy link

Describe the Bug

I’m not sure anyone else found this issue using GraphQL on the Edge.

This graphql query works fine locally (docker):

query ConsultantsBucket(
  $bucket: String
  $locale: String!
  $start: String!
  $amount: Int!
) {
  search(
    where: {
      AND: [
        { name: "_path", value: $bucket, operator: EQ }
        { name: "_language", value: $locale, operator: EQ }
        { name: "personIsActive", value: "1", operator: EQ }
      ]
    }
    first: $amount
    after: $start
    orderBy: { name: "personLastName", direction: ASC }
  ) {
    total
    results {
      url {
        path
      }
      updated: field(name: "__Updated") {
        value
      }
      changeFrequency: field(name: "ChangeFrequency") {
        jsonValue
      }
      priority: field(name: "Priority") {
        jsonValue
      }
    }
    pageInfo {
      hasNext
      endCursor
    }
  }

But when I push to the edge, I get this error:

{
  "errors": [
    {
      "message": "Argument \"where\" has invalid value",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "search"
      ]
    }
  ],
  "data": {
    "search": null
  }
}

To Reproduce

When it's the last item in the conditional array, I get the error: { name: "personIsActive", value: "1", operator: EQ }
This is also true of any template field I add, like "personLastName".

  • personIsActive is a checkbox
  • personLastName is a TextField

Once I make sure the template field isn’t the last item in my search conditions array it works.

query ConsultantsBucket(
  $bucket: String
  $locale: String!
  $start: String!
  $amount: Int!
) {
  search(
    where: {
      AND: [
        { name: "_path", value: $bucket, operator: EQ }
        { name: "personIsActive", value: "1", operator: EQ }
        { name: "_language", value: $locale, operator: EQ }
      ]
    }
    first: $amount
    after: $start
    orderBy: { name: "personLastName", direction: ASC }
  ) {
    total
    results {
      url {
        path
      }
      updated: field(name: "__Updated") {
        value
      }
      changeFrequency: field(name: "ChangeFrequency") {
        jsonValue
      }
      priority: field(name: "Priority") {
        jsonValue
      }
    }
    pageInfo {
      hasNext
      endCursor
    }
  }

Expected Behavior

I would expect it to work fine regardless of the order of the conditional objects, especially since it work locally in the docker setup.

Possible Fix

May be a something with parsing the query?

Provide environment information

  • Sitecore Version: XM Cloud
  • JSS Version: ~21.6.0
  • Browser Name and version:
  • Operating System and version (desktop or mobile):
  • Link to your project (if available):
@craighicks13
Copy link
Author

Wrong place for this

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

No branches or pull requests

1 participant