API Returns different data than playground

#import "@/graphql/fragments/ScStructuredText.graphql"

fragment BlogPostEssentials on PostRecord {
  id
  title
  slug
  excerpt
  publishedDate
  readingTime
  featuredImage {
    responsiveImage {
      ...DatoImage_responsiveImage
    }
  }
  author {
    name
    slug
    title
    bio
    picture: image {
      responsiveImage(imgixParams: { w: 48, h: 48, fit: crop }) {
        ...DatoImage_responsiveImage
      }
    }
  }
  category {
    name
    slug
    color { hex }
  }
  tags {
    tag
    slug
  }
  _publishedAt
}

fragment BlogPostFull on PostRecord {
  ...BlogPostEssentials
  content {
    ...ScStructuredTextContent
  }
  seoTags {
    title
    description
    image {
      url
    }
  }
  canonicalUrl
  sidebarContent {
    content {
      value
      blocks {
        ... on RecordInterface {
          id
          __typename
        }
        ... on InnerCtaBlockRecord {
          ...InnerCTABlock
        }
        ... on ButtonRecord {
          ...ButtonBlock
        }
        ... on ImageBlockRecord {
          id
          __typename
          image {
            responsiveImage {
              ...DatoImage_responsiveImage
            }
          }
        }
      }
      links
    }
  }
  featured
  noIndex
  tags {
    tag
    slug
  }
  showRelatedPosts
  manualRelatedPosts {
    ...BlogPostEssentials
  }
  _updatedAt
  _publishedAt
}```

Hi @dthreatt,

Could you please be more specific about what you’re seeing vs what you’re expecting to see? From your screenshot, it looks like you’re using a different query altogether (different & fewer fields, no fragments), so the results will naturally be different.

If that’s not what you mean, you might also want to double-check:

  • That both calls are using the same project
  • The same environment
  • The same API keys
  • The same draft/published status
  • That you’re querying the same records (either an individual one, or if multiple, that their sorting order and pagination are the same)

If it’s not any of those things, could you please be more specific as to what looks wrong to you, and we can take a deeper look?

Thank you!

I am not seeing the title field populated every in the project vs the playground it doesnt matter which keys I use or how different or the same the queries are. the title field is just never populated in the project. I am only referring to published status. in the playground I can get it to show the title in any project I can never get this title field to show up on this particular model on ANY record.

@dthreatt, I’m sorry, I’m a bit confused here… the queries look totally different to me. Can you send me a link to the model(s)/project(s) in question so I can take a look at your actual schema and see what you’re trying to fetch?

For example, it looks like your playground query is only asking for author.title… is that the one you want, or the blog post title?

In your fragments, I do see the title field (in BlogPostEssentials), but I don’t see the actual query in there, just the fragments. And in the screenshot you provided, I again see author.title, but it’s cropped so I don’t know what else was or wasn’t there. Could the post.title simply have been further up the screenshot, outside of the crop…? That’s what it looks like in your fragment, at least.

What exactly isn’t showing up for you, and what is the full query you’re using? Sorry, I can’t quite see the full chain of events here… it’s not clear from your screenshots what you’re actually querying and what is missing from the response.

Could you please provide:

  • The relevant URLs to these models/projects
  • The full query you’re sending
  • The full responses you’re getting back

Or if it’d be easier, maybe a screen recording would be easier, or we can jump on a live call? Sorry, I don’t have enough information yet to see what is going on :frowning:

Is this for project 148904 (the refactor project)?

If so, it looks to me like the titles are mostly working fine, except that some of your images don’t have their titles filled in:

Is that what you’re asking…? If that’s not the right title, sorry, I’m still confused :thinking: Which specific title field in which specific model are you looking for that’s not there, and what is the full query for it?

yes thats the project… I am not looking for image titles…I am looking for the job title of the authors.

Its only working in the playground not when I call it using the api call

allpost.author.title

And what is the full query you’re using in the API? Can you send us the actual HTTP request you’re making, or a curl command of it?

In your first post, I see some fragments, but not the actual query, or any of the associated headers, etc.

I’m sorry to keep asking… :sweat_smile: It’s hard to troubleshoot without knowing what’s being sent. The GraphQL playground isn’t doing anything magical; it’s just a UI that sends the same API calls you would, to the same endpoints. (You can capture its XHR requests and just replay them, or parse their request bodies to get the actual queries we send… it’s the same API either way.)

For example, if you use this query:

query MyQuery {
  allPosts(first: 500) {
    author {
      title
    }
  }
}

It should show the same results both in the playground and in the API. If it doesn’t, something is different… maybe an API key, or an environment, or some sort of caching, etc.

If you could please share the full request — query, headers, variables, etc. — it would really help :pray:

All of a sudden it just started working. I didnt change anything. Did you guys do something??

@dthreatt There were no recent changes that I know of. Without fully understanding what the issue even was originally, we can’t trace it any further :frowning: Maybe it was a caching issue of some sort…? It’s hard to say when we still don’t know what you were seeing at first… I’m sorry, we really do need more detail.