For example I want: ``` type Location { longitu...
# orm-help
d
For example I want:
Copy code
type Location {
  longitude: Float!
  latitude: Float!
}
I don't want this as a table, I just want to use it on another type:
Copy code
type Post {
  ...
  location: Location!
}
Any ideas?
w
You’re mixing your datamodel and your GraphQL schema. Prisma’s GraphQL API should not be used directly, but rather using a GraphQL API that you’ll create on top of it. If you want a Location type that isn’t in your database, then you have to add it on the schema of your GraphQL server that seats on top the Prisma’s one
d
So for anything like that I should just use a Json type?
(I'm storing it in PostgreSQL as a JSON type.
n
you should use a prisma with mongodb probably
d
How's that make a difference to my problem.
n
it will allow you to do what you are refering too
use graphql yoga maybe
w
I don’t get it, how will a JSON type solve your problem? You want to expose a type that is not in your database. You cannot do that from your datamodel
d
I am using graphql yoga.
Not sure how else I can solve it without a JSON type. It's stored in the database as JSON.
w
But you explicitely said that you didn’t want to store it in your database
n
are you referring to an embedded
type?
d
Where did I say that? I literally said I'm storing it in PostgreSQL as a JSON type.
n
I don't know about PostgreSQL
But prisma docs as example for mongodb
w
I misunderstood your problem, apologies. By not having a table, I thought that was a way to say you didn’t want to store it. Then yeah, a JSON type is probably the way to go for now, unless there’s a better way that I’m not aware of
n
for embedded type
w
Mongodb might not be a great fit for his use-case here
n
why not?
d
I'm not using MongoDB, I'm using PostgreSQL.
w
Because MongoDB is not a relational db and have different use-cases than document-based db To sum-up here daryl (and forgive me for not understanding your problem), yeah, you should probably go with a json type. AFAIK, postgres does index
jsonb
, but I don’t know whether Prisma uses
json
or
jsonb
internally
d
Sucks though because a Json type can be anything
w
But the problem here is not prisma but rather what you’re trying to achieve. You’re basically trying to emulate an embedded type which is a concept of document-based db, not relational ones
d
Yeah I suppose
w
What’s the reason for not wanting a table?
d
No need to query this data.
w
Then why is it stored?
d
Because it's meta.
Copy code
input OpenTimeInput {
  monday: OpenDayInput
  tuesday: OpenDayInput
  wednesday: OpenDayInput
  thursday: OpenDayInput
  friday: OpenDayInput
  saturday: OpenDayInput
  sunday: OpenDayInput
}

input OpenDayInput {
  open: String!
  close: String!
}
I also have this too, which would create two tables when it's just information about a place (meta). Imagine they're types, not inputs.
Just like you wouldn't query a post description (in most cases), but you store it because it's data that's needed.
w
What’s wrong with having actual tables and just hiding the field from your graphql api that seats in front of the prisma’s one?
d
I don't like it. Seems silly having redundant tables.