Is it possible to have deep/nested fields in a sch...
# prisma-whats-new
g
Is it possible to have deep/nested fields in a schema?
y
@gustavo_pch You can nest by creating new nodes and then linking through relations.
So if you have a User node defined as
Copy code
{
id
name
}
You can add a new node Plan defined as
Copy code
{
id
name
price
}
And then create a relation between the two nodes, so then your User node would become
Copy code
{
id
name
plan {
  id
  name
  price
  }
}
g
Thank you, @yergi! One more question: when should my types implement
Node
? Always?
c
i guess its a requirement of GraphCool. If you building schema in console it would be added automatically
y
Think of Node like a SQL table.
@checkmatez - If you create the relationship then graphQL (and GraphCool) automatically know what fields belong to the two nodes, you don’t have to redefine the User node to include plan and all its fields. I was just trying to show how the nesting would look when you perform a query on nodes with relations. 🙂
c
Yeah, i know that, thanks 🙂
y
Sorry, guess I misunderstood what you meant when you said “it’s a requirement of GraphCool”.
c
I mean, the string
Copy code
type Company implements Node {
is automatically added whenever you add new type in console.
So i think, you should add "implements Node" if you making schema outside of console. But i might be wrong 🙂
y
Oh, gotcha. That’s the actual GraphQL syntax that the GraphCool console is performing behind the scenes. You’d need to use that if you were writing a schema file and uploading to GraphCool via their CLI.
c
Thats what i said to @gustavo_pch 🙂
y
So it is. Sorry, I’m clearly not fully awake yet.
c
No problem 🙂 Go get some coffee and come back 🙂
n
So i think, you should add "implements Node" if you making schema outside of console. But i might be wrong 🙂 (edited)
if you use the CLI or the Console, we will automatically add
implements Node
🙂
ping @yergi @gustavo_pch @checkmatez
g
@nilan And why is this
implements Node
needed?
y
@nilan Then I don’t need to be using that syntax when editing / updating the
project.graphcool
file and pushing / pulling that via the CLI?
That’s what I’ve been doing and it’s worked.
n
You can include it, but both the CLI and Console add it automatically 🙂