Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Where to get resources to learn Designing Your Schema for dummies, I tried building my graphql schema using the new transformer v2 (fails)

I tried building my own schema but keep getting [Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'post.save.items')]

I've been shuffling, changing my schema but it either gives me results I didn't want,lacks values I needed or just keeps failing. I am clearly not getting the hang of it. Is there any article that offers over-simplified explanation?

And in case anyone has got a second to spare, you can take a look at my schema and correct/explain what I am doing wrong. Cheers

My Schema

type User @model {
  id: ID!
  username: String
  posts: [Post] @hasMany
}
type Post @model {
  id: ID!
  photo:String
  userID: ID!
  user: User @hasOne(fields: ["userID"])
  saves: [Save]@hasMany(fields: ["id"])
}

type Save @model(queries: null) {
  id: ID!
  userID: ID!
  postID: ID!
}

And then I edited my listPosts queries from:

export const listPosts = /* GraphQL */ `
  query ListPosts {
    listPosts {
      items {
        id
        photo
        userID
        user {
          id
          username
        }
        saves {
          nextToken
        }
        userPostsId
      }
      nextToken
    }
  }
`;

To:

 export const listPosts = /* GraphQL */ `
      query ListPosts {
        listPosts {
          items {
            id
            photo
            userID
            user {
              id
              username
            }
            saves {
              items {
              id
              userID
              postID
            }
            userPostsId
          }
          nextToken
        }
      }
    `;

My initial intention was to have a user register with a simple username. Get presented with a list of posts(photos) and save any of them if they wanted to. A save would be made up of an object containing the save id,the user's id and the post id. If I query for listPosts all the photos are successfully relayed, but it lacks the save object and throws the error :[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'post.save.items')]

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!