for example an address field! In Graphql I could u...
# prisma-whats-new
m
for example an address field! In Graphql I could use an interface of Address then declare my address of Address type.....how do I do that in Graphcool Types file?
j
Are you suggesting something like this?
Copy code
type Address {
    city: String
    state: String
    ...
}

type Person {
    name: String
    address: Address
}
m
yes.....can I do this?
j
Yes, at least in Prisma - are you using Prisma or are you using graphcool-framework?
m
graphcool framework
I also got caught by the package.json DESTROYER.....I this they need to fix thsi....at least put a overwrite message
j
I think the only way to handle this in gcf is to actually define a new type and add a relation field wherever you want to use it
The more robust "embedded types" only came with Prisma, which isn't included in gcf yet
m
I will take a look at Prisma....but what is the json type?
j
It's just that - if you set the field as
JSON
it'll expect valid JSON data
You can't query off of it or anything though, it just gets returned in a chunk
m
umm and here I thought maybe you could assing it {a1,b2} ...I guess i was ambitious
Thanks a lot for for help...maybe you could give me an example of "define a new type.." you mentioned above.
My final question is...this is a very common requirement...so how it handled normally?
j
Well, per your first comment, if you have
Copy code
type T @model {
    data: JSON
}
the
data
field could be
{a:1,b:2}
- however, you couldn't construct a query like
Copy code
query {
    T {
        data(b: 4) {
            a
        }
}
or anything like that
As far as defining a new type, in GCF you would see something like
Copy code
type Address @model {
    city: String
    state: String
    ...
    people: [Person!]! @relation(name: 'PeoplesAddresses')
}

type Person @model {
    name: String
    address: Address @relation(name: 'PeoplesAddresses')
}
or something like that - I haven't used gcf, so I'm going off of my memory of what I've seen
m
Ummm....thanks