0

I'm struggling with the Prisma API, maybe I'm confusing a little, when I try to query by some field of the model which is a unique field, and using playground I got an error. Let me put in context.

type Organization {
    id: ID!
    name: String!
    staff: [Employee!]!
}

type Query {
    organization(id: ID!): Organization!
    organizations: [Organization]!
    organizationByName(name: String!):Organization! //This is the one with the error
}

This is the prisma datamodel

type Organization {
    id: ID! @unique
    name: String! @unique
    staff: [Employee!]!
}

and this is the prisma schema generated (the part that are for interest)

input OrganizationWhereUniqueInput {
  id: ID
  name: String
}

finally, the resolver:

function organizationByName(parent, {name}, context, info) {
  return context.prisma.organization({name: name});
}

When I hit the query:

query{
  organizationByName(nombre:"Bitas"){
    id
    name
  }
}

I got the error:

Reason: 'name' Field 'name' is not defined in the input type 'OrganizationWhereUniqueInput'

but as you can see on the generated schema, there is a name field... so I'm confused, could please somebody point me to the right direction, I'm newbie to GraphQL

Note: Also if I wanna resolve using where clause, I got the kinda same error but something like where field is not defined in the input type

Thanks in advance

2
  • It looks like you are using nombre: "Bitas" instead of name: "Bitas"
    – Errorname
    Mar 28, 2019 at 15:58
  • You are running a query against the Prisma endpoint, and not against the endpoint that uses the schema you defined.
    – marktani
    Apr 1, 2019 at 13:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.