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

Accomodate "sys" in content queries #245

Open
rileyjhardy opened this issue Oct 21, 2021 · 4 comments
Open

Accomodate "sys" in content queries #245

rileyjhardy opened this issue Oct 21, 2021 · 4 comments

Comments

@rileyjhardy
Copy link
Contributor

Currently the gem does not require specifying "sys" within queries such as...

Page.find_by({ meta: { sys: { id: "someid" } } })

However we want to accomodate the case where we do provide "sys" since that is the actual structure of the content type. We don't want the request adding an additional "sys" as in the screenshot below.

wcc-contentful bug

Below is how the Page object structured

{
{
    "metadata": {
        "tags": []
    },
    "sys": {
        "space": {
            "sys": {
                "type": "Link",
                "linkType": "Space",
                "id": "hw5pse7y1ojx"
            }
        },
        "id": "4MLOHjOkA3lBAWz6WPIDQK",
        "type": "Entry",
        "createdAt": "2020-04-29T00:25:26.141Z",
        "updatedAt": "2021-10-14T17:32:19.511Z",
        "environment": {
            "sys": {
                "id": "master",
                "type": "Link",
                "linkType": "Environment"
            }
        },
        "revision": 18,
        "contentType": {
            "sys": {
                "type": "Link",
                "linkType": "ContentType",
                "id": "page"
            }
        },
        "locale": "en-US"
    }...
@jpowell
Copy link
Member

jpowell commented Oct 22, 2021

Ahhh - we do allow for querying sys, but not after doing a join, i suppose... @gburgett can you confirm?

@jpowell
Copy link
Member

jpowell commented Oct 22, 2021

Actually, @rileyjhardy, I believe Page.find_by({ meta: { id: "someid" } }) works... no need for sys

@gburgett
Copy link
Member

Yep that's the workaround! Still think in an ideal world Riley's query should be handled

@jpowell
Copy link
Member

jpowell commented Oct 22, 2021

we can agree to disagree :trollface: - i think the ideal is that the id is accessed like any other attribute, obfuscating the nuance introduced by contentful's schema... the intent was that it behaved similar to active record.

But yes - if you choose to query mimicking the underlying structure, it should work 😺

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

No branches or pull requests

3 participants