wp-graphql / wp-graphql-tax-query

Adds `tax_query` support to postObject connection queries using WP_Query
46 stars 16 forks source link

LoadKeys error on query. Successful results. #9

Closed joseffb-mla closed 5 years ago

joseffb-mla commented 5 years ago

Error:

"debugMessage": "Method WPGraphQL\\Data\\Loader\\PostObjectLoader::loadKeys is expected to return array, but it threw: No item was found with ID 1218",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 24,
          "column": 17
        }
      ],
      "path": [
        "apples",
        "edges",
        5,
        "node",
        "featuredImage"
      ]
    },

Query:

query ($uri: String){
    apples (
        where: {
            taxQuery: {
                taxArray: [
                    {
                        terms: [$uri],
                        taxonomy: KEYWORD,
                        operator: IN,
                        field: SLUG
                    }
                ]
            }
        }
    ){
        edges{
            cursor
            node {
                appleId
                title ... (more fields)

So I get results in the data part of result, but inthe error area of result I'm given the LoadKey error for each result. Not sure whats wrong here.

jasonbahl commented 5 years ago

It looks like it had trouble getting a featuredImage

Does one of the posts have a featured image assigned but the image has since been deleted?

jasonbahl commented 5 years ago

Based on the path of the error:

"path": [
        "apples",
        "edges",
        5,
        "node",
        "featuredImage"
      ]
jasonbahl commented 5 years ago

can you also share the results of the query?

joseffb-mla commented 5 years ago

Ok that makes sense as it’s dummy data.

How do you prevent this in a general sense as some may have images others not?

Regards, Joseff


Joseff Betancourt Sr. Website Developer jbetancourt@mla.org

On Apr 10, 2019, at 1:37 PM, Jason Bahl notifications@github.com wrote:

It looks like it had trouble getting a featuredImage

Does one of the posts have a featured image assigned but the image has since been deleted?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wp-graphql/wp-graphql-tax-query/issues/9#issuecomment-481788977, or mute the thread https://github.com/notifications/unsubscribe-auth/Aq5Zk1trpx8zNSgMZOfV6_fpsbNGOy2Cks5vfiFGgaJpZM4cn3hg.

jasonbahl commented 5 years ago

Well, without knowing your dataset, my guess is you have a post that has a thumbnail_id as meta, but that ID is either invalid or belongs to an image that's since been deleted. Just a guess.

The error doesn't mean that your application will break, just that a particular node wasn't found.

Check that 5th apple's featured image ID and see if it's valid or not

jasonbahl commented 5 years ago

is ID 1218 a featured image ID? or a post ID?

joseffb-mla commented 5 years ago
"data": {
    "apples": {
      "edges": [
        {
          "cursor": "YXJyYXljb25uZWN0aW9uOjEyMTc=",
          "node": {
            "appleId": 1217,
            "title": "Introduction to title",
            "slug": "introduction-to-title",
            "content": "some html content <p>here here here</p>",
            "featuredImage": null,
            "tags": {
              "edges": [
                {
                  "node": {
                    "name": "Assignments"
                  }
                },
                {
                  "node": {
                    "name": "getting started"
                  }
                },
                {
                  "node": {
                    "name": "Syllabi"
                  }
                },
                {
                  "node": {
                    "name": "Video"
                  }
                }
              ]
            },
            "genres": {
              "edges": [
                {
                  "node": {
                    "name": "Syllabus"
                  }
                }
              ]
            },
            "keywords": {
              "edges": [
                {
                  "node": {
                    "name": "Video"
                  }
                }
              ]
            },
            "authors": {
              "edges": [
                {
                  "node": {
                    "name": "David"
                  }
                }
              ]
            },
            "citations": {
              "edges": []
            },
            "related_works": {
              "edges": []
            }
          }
        },...more
joseffb-mla commented 5 years ago

1218 would be an appleID

jasonbahl commented 5 years ago

can you share the results of apple 1218?

joseffb-mla commented 5 years ago

Hmm it's not in the results. Looks like it got skipped. I believe that one does have an image uri -- double checking.

jasonbahl commented 5 years ago

can you share the full results of that query? in a GIST or something if it's too long for these comments?

joseffb-mla commented 5 years ago

I think it's an orphaned record from my master db to my dev db. One sec (checking). or not. ...

jasonbahl commented 5 years ago

but, this is actually one of the neat things about GraphQL, in my opinion. . .even if there's a partial failure somewhere, it doesn't kill the entire request like most REST APIs would.

You can still get the data that is successful and troubleshoot the errors without your entire app breaking

joseffb-mla commented 5 years ago

yea its nice.

So I'm not finding a 1218 (via wp edit screen) in my test db. But then I'm wondering how it's finding it in graphql. Also I did a video tax query but my video tax doesnt have any articles attached to it (was a partial import from master db due to size).

hmm

joseffb-mla commented 5 years ago

ok sorry it does have video tags (but the count on the keyword tax page isn't working for some reason.)

joseffb-mla commented 5 years ago

ok so seems the tax is looking for 1218 for some reason (which doesn't exist).

No item was found with ID 1218 -- which is correct because it doesn't exists. odd

jasonbahl commented 5 years ago

@joseffb-mla it looks like it's a meta field, on a post. I believe 1218 is a featured image ID, but that featured image was deleted.

So, when you're asking for

  node {
     feauturedImage
  }

It tries to load image 1218

jasonbahl commented 5 years ago

check the post_meta for the posts and see if any of them have thumbnail_id set to 1218

joseffb-mla commented 5 years ago

ah ok I think I got it -- makes sense because media are post too

joseffb-mla commented 5 years ago

Indeed these are error messages from orphaned post_meta's.

jasonbahl commented 5 years ago

πŸ’₯

Sweet!!!

jasonbahl commented 5 years ago

I think we can close this issue, eh?

joseffb-mla commented 5 years ago

I'll need to return to this to ensure featuredImage works (just tried it and its still showing up null), but I think that solves this specific ticket.

joseffb-mla commented 5 years ago

Thanks Jason, your a super star for actually spending time helping me reside these issues.

jasonbahl commented 5 years ago

@joseffb-mla my pleasure. Consider writing a blog post or something about your experience with WPGraphQL. Share the good news of how awesome this tech is πŸ˜„

joseffb-mla commented 5 years ago

Yea I'm planning on putting together some examples for the docs page as we discussed. Just want to get this app unto my dev servers (off local). I'm learning up Apollo client at moment and learning tons along the way.

jasonbahl commented 5 years ago

Apollo is Amazing! I actually teach a course on Apollo. . .it's in-person though. Hope to have time to convert it to an online course at some point. πŸ˜„

joseffb-mla commented 5 years ago

Off topic: Is there a GraphQL Slack that you know of? Cause I do have some q's about the client->query, and redux implmentation. (although more info at this point since i mustered past into enlightenment already lol).

Seems everything is react components and no easy way to get data object. I finally figured it out though.

jasonbahl commented 5 years ago

Apollo recently moved off slack to Spectrum.chat here: https://spectrum.chat/apollo

Apollo has it's own version of local state management to essentially replace Redux. You can still use Redux if you need to, but many seem to find it easier to use Apollo Local State.

jasonbahl commented 5 years ago

We also have a WPGraphQL slack that you can join here: https://wpgql-slack.herokuapp.com/ and a WPGraphQL Spectrum here: https://spectrum.chat/wpgraphql