miragejs / graphql

A library for handling GraphQL requests with Mirage JS
MIT License
74 stars 12 forks source link

RelationShip #41

Closed lucasmoura-boticario closed 3 years ago

lucasmoura-boticario commented 3 years ago

Hello, how to get all tickets ?

seed: server.schema.listTickets.create({ total: 1, tickets: server.schema.tickets.all() });

query: getTickets(limit: Float, init: Float, userEmail: String!): ListTicket

type ListTicket {
  total: Int!
  tickets: [Ticket!]!
}

type Ticket {
  id: String!
  status: String
  category: String
  subject: String
  url: String
}

Response: Cannot return null for non-nullable field Query.getTickets.

jneurock commented 3 years ago

Hmm, this could be the auto-filtering functionality causing an issue. Are you supplying any variables to your query? If so, Mirage GraphQL will try to use those variables to filter records by assuming the records have a corresponding field name that matches the variable name (see this section). If this is the case, you'll need to supply a resolver (see example here).

If you're not supplying any variables, you can debug and check if Mirage's DB actually has ListTicket records just in case the seeds aren't working as expected.

lucasmoura-boticario commented 3 years ago

about the problem above, it was with the wrong name in the query! Now I can't just make the relationship

I was playing in the repl and trying to make the relationship, see if you can help me I'm having difficulties I believe that would be the problem when extending the model

https://miragejs.com/repl/v2/ba50569dc5

jneurock commented 3 years ago

about the problem above, it was with the wrong name in the query! Now I can't just make the relationship

I was playing in the repl and trying to make the relationship, see if you can help me I'm having difficulties I believe that would be the problem when extending the model

https://miragejs.com/repl/v2/ba50569dc5

I took a look at the REPL link but I can't quite figure out what the problem is. 😅 What about the relationship?