I have a type defined as ``` type TeamGoalMeta { ...
# prisma1-community
j
I have a type defined as
Copy code
type TeamGoalMeta {
  id: ID! @id
  goal: TeamMeasurement!
  upperTriggerFrom: Int,
  upperTriggerTo: Int,
  lowerTriggerFrom: Int,
  lowerTriggerTo: Int,
  company: Company!
}
and then in my graphQL I have
Copy code
teamGoalMeta(goalId: ID!): TeamGoalMeta!
but when I query the API
Copy code
query {
  teamGoalMeta(goalId:"ckdrfe75227p70a355f2bmavk") {
   	id  
  }
}
I get the following
Copy code
Error: Variable '$where' expected value of type 'TeamGoalMetaWhereUniqueInput!' but got: {"goalId":"ckdrfe75227p70a355f2bmavk"}. Reason: 'goalId' Field 'goalId' is not defined in the input type 'TeamGoalMetaWhereUniqueInput'. (line 1, column 8):
"Variable '$where' expected value of type 'TeamGoalMetaWhereUniqueInput!' but got: {\"goalId\":\"ckdrfe75227p70a355f2bmavk\"}. Reason: 'goalId' Field 'goalId' is not defined in the input type 'TeamGoalMetaWhereUniqueInput'. (line 1, column 8):\nquery ($where: TeamGoalMetaWhereUniqueInput!)
r
I think there’s an issue in your Prisma query. Could you share that as well?
j
Copy code
return context.prisma.teamGoalMeta({where: { goalId: goalId }});
The mutation works
Copy code
mutation {
  createTeamGoalMeta(
    goalId: "ckdrfe75227p70a355f2bmavk",
    upperTriggerTo: 10,
    upperTriggerFrom: 0,
    lowerTriggerTo: 100,
    lowerTriggerFrom: 5
  ) {
    id
  }
}
and the data is stored correctly.
r
goalId
is not unique. Could you check the generated Prisma types for this type
TeamGoalMetaWhereUniqueInput
and what it expects?
j
Copy code
export type TeamGoalMetaWhereUniqueInput = AtLeastOne<{
  id: Maybe<ID_Input>;
}>;
and
Copy code
teamGoalMeta(where: TeamGoalMetaWhereUniqueInput!): TeamGoalMeta
  teamGoalMetas(where: TeamGoalMetaWhereInput, orderBy: TeamGoalMetaOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [TeamGoalMeta]!
  teamGoalMetasConnection(where: TeamGoalMetaWhereInput, orderBy: TeamGoalMetaOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): TeamGoalMetaConnection!
r
It’s
id
and not
goalId
so you would need to change that in your Prisma query.
j
Copy code
type TeamGoalMeta {
  id: ID!
  goal: TeamMeasurement
  upperTriggerFrom: Int
  upperTriggerTo: Int
  lowerTriggerFrom: Int
  lowerTriggerTo: Int
  company: Company!
}
But I am looking for the teamgoalmeta where the goal of the team goal meta table is x
r
But there’s no field named
goalId
in your
TeamGoalMeta
type
j
yeah there will not be but there is goal.
r
Then you’re querying it incorrectly. You have to query that first and then goal.
j
yeah thanks I just had the lightbulb moment 😛
Copy code
type TeamGoalMeta {
  id: ID!
  goalId: String
  upperTriggerFrom: Int
  upperTriggerTo: Int
  lowerTriggerFrom: Int
  lowerTriggerTo: Int
  company: Company!
}
Copy code
teamGoalMeta(parent, { goalId }, context) {
    return context.prisma.teamGoalMeta({ where: { goalId: goalId } });
  },
Copy code
type TeamGoalMeta {
  id: ID! @id
  goalId: String,
  upperTriggerFrom: Int,
  upperTriggerTo: Int,
  lowerTriggerFrom: Int,
  lowerTriggerTo: Int,
  company: Company!
}
still fails the same way
Copy code
"message": "Variable '$where' expected value of type 'TeamGoalMetaWhereUniqueInput!' but got: {\"where\":{\"goalId\":\"ckdrfe75227p70a355f2bmavk\"}}. Reason: 'where' Field 'where' is not defined in the input type 'TeamGoalMetaWhereUniqueInput'. (line 1, column 8):\nquery ($where: TeamGoalMetaWhereUniqueInput!) {\n       ^",
r
Omit the
where
and try
j
Copy code
export interface TeamGoalMetaUpdateDataInput {
  goalId?: Maybe<String>;
  upperTriggerFrom?: Maybe<Int>;
  upperTriggerTo?: Maybe<Int>;
  lowerTriggerFrom?: Maybe<Int>;
  lowerTriggerTo?: Maybe<Int>;
  company?: Maybe<CompanyUpdateOneRequiredInput>;
}
Copy code
"message": "Variable '$where' expected value of type 'TeamGoalMetaWhereUniqueInput!' but got: {\"goalId\":\"ckdrfe75227p70a355f2bmavk\"}. Reason: 'goalId' Field 'goalId' is not defined in the input type 'TeamGoalMetaWhereUniqueInput'. (line 1, column 8):\nquery ($where: TeamGoalMetaWhereUniqueInput!) {\n       ^",
Copy code
export type TeamGoalMetaWhereUniqueInput = AtLeastOne<{
  id: Maybe<ID_Input>;
}>;
seems to still point to ID
urg
Copy code
z    return context.prisma.teamGoalMeta({ goalId: goalId });
r
goalId
should be unique which is why you cant get it.
Copy code
type TeamGoalMeta {
  id: ID! @id
  goalId: String @unique,
  upperTriggerFrom: Int,
  upperTriggerTo: Int,
  lowerTriggerFrom: Int,
  lowerTriggerTo: Int,
  company: Company!
}
The
@unique
would be required to get a single record.
j
ok I might need sleep