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

Entries not loading relations #8

Open
jonvanputten opened this issue Jun 30, 2017 · 6 comments
Open

Entries not loading relations #8

jonvanputten opened this issue Jun 30, 2017 · 6 comments
Assignees
Labels

Comments

@jonvanputten
Copy link

Hey Devs,

I have a Blogpost that contains one or more Authors. If I do:
Contentful.Delivery.entries(@space_id, @access_token)

I will get the content with the relations, but with nil:
%{"fields" => %{"author" => [nil, nil], "title" => "The article"

Even if I add the %{"include" => 2} as the search parameter, I will still get a nil. Is there another way to load the relations or am I doing it wrong?

@dlitvakb
Copy link
Collaborator

dlitvakb commented Aug 4, 2017

Hey @jonvanputten,

I'll take a look into it as soon as I can and let you know what I found.

Cheers

@dlitvakb dlitvakb added the bug label Aug 4, 2017
@dlitvakb dlitvakb self-assigned this Aug 4, 2017
@floriank
Copy link
Collaborator

floriank commented May 8, 2020

@jonvanputten I know this is old, but could you try on recent master if the error is present with the new release?

@leohoe
Copy link

leohoe commented Jan 14, 2021

The error is still present - the include parameter added with include/2 does not lead to any relations actually loading.

    with {:ok, [entry], total: 1} <-
      Entries
      |> content_type("articleTemplate")
      |> by(id: entry_id)
      |> include(5)
      |> fetch_all()
      |> IO.inspect()
    do
      conn
      |> assign(:entry, entry)
      |> render("article_template_test.html")
    end

The output of IO.inspect() was no different from when include/2 is omitted entirely.

@evayde
Copy link

evayde commented Mar 18, 2021

Hello, the issue here might be that resolve_collection_response only resolves Asset in includes and not Entry. So linked entries are indeed never getting through to the client.

@WillRochaThomas
Copy link

WillRochaThomas commented Apr 29, 2024

@jonvanputten @leohoe @evayde did anyone find a workaround? I'm encountering this issue now, I can see the call the library makes to the Contentful API is getting a lot of linked Entries in the 'include' section of the response, but haven't yet found a way to access these via the client library.

It looks like most of the functions that fetch_all calls are public, so a potential short-term hack around this might be to create a function in our code that has the same logic, but passes a different callback to Delivery.parse_response/2 at this point, which does keep hold of the entries in 'includes'

|> Delivery.parse_response(&queryable.resolve_collection_response/1)
.

@WillRochaThomas
Copy link

I've created a PR to address this #181

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

6 participants