```type Thing { id: ID! @id value: String }```...
# orm-help
s
Copy code
type Thing {
  id: ID! @id
  value: String
}
Copy code
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ thing { value } }" }' <http://localhost:4466>
Field 'thing' argument 'where' of type 'ThingWhereUniqueInput!' is required but not provided.
d
You're querying a single record. How is Prisma supposed to know which one you want? The answer is it can't, and you need to provide the required information. I recommend you explore the Playground a bit (usually on the / route of your setup), it has a
schema / docs
section on the right that helps you get a feeling.
j
auto-complete is nice
s
thanks, the playground with docs is helpful... i'm still confused, though ;(
Copy code
mutation {
  createThing(
    value: "something"
  )
}
Field 'createThing' of type 'Thing' must have a sub selection
e
^ it is expecting you to ‘ask’ for a/some returned values. You could try:
Copy code
mutation {
  createThing(
    value: "something"
  ) {
    value
  }
}
value
being exchangeable (or in addition) for
id
, based on the type you posted
s
Unknown argument 'value' on field 'createThing' of type 'Mutation'
Field 'createThing' argument 'data' of type 'ThingCreateInput!' is required but not provided.
d
Copy code
mutation {
  createThing(data: {
    value: "something"
  }) { value }
}
s
why must i use
data
?
j
This is basic graphql syntax
d
Because the API defines it.
s
i didn't define it 😞
there's no "data:" in graphql documentation
d
You should take a step back and take a look on what you're dealing with right now. On the one hand you have GraphQL, which defines a syntax and protocol to query data. On the other hand is Prisma, which generates a GraphQL API for you based on the datamodel you give it.
s
okay.. how can the data key requirement be avoided?
it just doesn't look nice to me
d
You can't. End of story. If you want to build your own GraphQL server that exposes the API you want, you will have to put in the work yourself, but have full control.
s
is it that much work to do so?
d
As much or as little as your requirements dictate.
s
alright... well, back to your example above.. it responded with:
Copy code
{
  "data": {
    "createThing": {
      "id": "cjwglyrcy009p0766jlt4tax8"
    }
  }
}
why does it need data and createThing keys?
e
that is just how the data is returned through the query/mutation.
data
signifying that its.. data, and
createThing
is the name of the query/mutation hit
d
I recommend you look up the basics of the GraphQL JSON based protocol.
s
would graphiql be easier, then?
e
graphiql is just a different interface, serves the same purpose as /playground
s
so, even with a custom api, it'd always return data/createThing keys?
e
as far as i have created production api’s using prisma, yes
s
actually.... i think that makes sense because i could perform multiple mutations in a single call... am i correct?
e
I think that is part of the GraphQL JSON protocol as @dpetrick mentioned
s
okay.. it's just the "data" part i don't like, but i'm not a backend programmer
thank you both!
👍 1
e
consuming the response with destructuring assignment is fairly succinct 🙂
j
If you want a backend that "just works", Hasura is a great option.
👍 1