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 - entry uri filter does not work with multisite #4054

Closed
valschr opened this issue Jul 27, 2021 · 2 comments · Fixed by #4055
Closed

GraphQL - entry uri filter does not work with multisite #4054

valschr opened this issue Jul 27, 2021 · 2 comments · Fixed by #4055

Comments

@valschr
Copy link

valschr commented Jul 27, 2021

Bug Description

When querying an entry using the "uri" filter localized URLs return null instead of the entry.

How to Reproduce

This does return a result

entry(uri: "/careers") {
    id
    site {
      name
    }
}

This returns null (I verified that the entry exists, is translated and published)

entry(uri: "/gb/careers") {
    id
    site {
      name
    }
}

sites.php

'sites' => [
        'default' => [
            'name' => 'English US',
            'locale' => 'en_US',
            'url' => env('APP_URL'),
        ],
        'gb' => [
            'name' => 'English GB',
            'locale' => 'en_GB',
            'url' => env('APP_URL').'gb/',
        ],
    ],

Since there can be multiple pages with the same slug it is impossible to query a translated pages via the entry endpoint.

This is the workaround I'm currently using

entries(collection: "pages", limit: 1, filter: {uri: {is: "/careers"}, site: {is: "gb"}}) {
    current_page
    data {
      id
      title
      site {
        url
        locale
        name
        handle
        short_locale
      }
      uri
      url
    }
  }

Extra Detail

Environment

Statamic version: 3.1.30

PHP version: 7.4.19

Install method (choose one):
Fresh install from statamic/statamic

@jasonvarga
Copy link
Member

The uri of the entry on the gb site would still be /careers. The /gb is not included in the uri. (The url has it.)

I'd suggest adding a site argument to your query, but it looks like we haven't added that yet. I've done this in #4055.

You'll be able to do:

entry(uri: "/careers", site: "gb") {
  # ...
}

@valschr
Copy link
Author

valschr commented Jul 29, 2021

awesome, thank you!

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 a pull request may close this issue.

2 participants