hey Guys I'm playing with example from documentat...
# prisma-whats-new
a
hey Guys I'm playing with example from documentation:
Copy code
type Tweet {
  id: ID! @unique
  createdAt: DateTime!
  text: String!
  owner: User!
  location: Location!
}
 
type User {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  handle: String! @unique
  name: String
  tweets: [Tweet!]!
}
 
type Location {
  latitude: Float!
  longitude: Float!
}
and I'm having some issue. When I update user location few times (via
location > create
mutation as there is no other way), and then I query for
locations
I'm having many
location
zombie data rows and it's not possible to remove them. Is that issue or I'm doing something wrong?
h
you can't remove them?
a
technically yes. Location has no id so there will be a lot of identical rows there
there is no way to distinguish rows that have same values
so there is no safe way to run
deleteManyLocations
mutation
also, as I just want to
update
location of some tweet, I dont really want to ‘clean’ after myself. Goal was to update location, not to create new
location
row
I run this mutation few times:
Copy code
mutation {
  updateTweet(data: {
    location: {
      create: {
        latitude: 10,
        longitude: 10
      }
    }
  }, where: {
    id: "cjcs5tn80000u0113h5fzxp2y"
  }) {
    id
  }
}
and then when I query for
locations
I get
Copy code
{
  "data": {
    "locations": [
      {
        "longitude": 234,
        "latitude": 34
      },
      {
        "longitude": 11,
        "latitude": 11
      },
      {
        "longitude": 11,
        "latitude": 11
      },
      {
        "longitude": 11,
        "latitude": 11
      },
      {
        "longitude": 11,
        "latitude": 11
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      },
      {
        "longitude": 10,
        "latitude": 10
      }
    ]
  }
}
even tho there is only one tweet. Those are zombie.
what do you think?
you there @harmony?
h
oh sorry
hmm
are you using prisma?
it's probably possible there somehow
a
yup, I’m using Prisma
It’s no way to identify it I’d say
also, for use-case of ‘updating’ location I think new row should not be created. Whole point of
create
in uni-directional relation I’d say is not needed here
anyway - no way to remove those rows..
being sure youre not removing good ones
h
yeah, without ids it's hard
a
🙂
I think this is popular use case and this is serious issue
also, why is there
create
even needed in uni-directional relations instead of
Copy code
mutation {
  updateTweet(data: {
    location: {
      lat: 20
    }
  }, where: {
    id: 'ID HERE'
  })
}
h
I'm guessing because it's a separate type
maybe add an id and on update delete the old one