DEV Community

Bimo Prasetyo Afif
Bimo Prasetyo Afif

Posted on

graphql, with egde and node or not?

hi guys, i am new about learning graphql (a week) and i just confused about query typing

why we should create edge and node in query? and what it does mean?

Top comments (5)

Collapse
 
oncle_flingueur profile image
Laimis

Apa kabar, Bimo!

The Node interface means that your types will be forced to have an id field.

There is a nice example here: atheros.ai/blog/graphql-interfaces...

If your types will have a Node interface, it will be much easier to query them by id.

Another advantage of Node is Connection which lets you put extra fields on itself and on the edges of the node. Example: docs.graphene-python.org/en/latest...

Collapse
 
bimbimprasetyoafif profile image
Bimo Prasetyo Afif

yup, and i just found an article that implement graphQl and vue.js

and now, i knew that works. thanks for information ๐Ÿ˜† i thought this (graphQl) very very very fuuuunnnnnn

Collapse
 
ale_jacques profile image
Alexandre Jacques

AFAIK, Edges and Nodes are used by Relay client (React - relay.dev/). Somebody please correct me if I'm wrong.

Collapse
 
bimbimprasetyoafif profile image
Bimo Prasetyo Afif • Edited

ahh i see. is it okay even doesn't use relay in server? i don't know what relay used for :")

Collapse
 
oncle_flingueur profile image
Laimis

The Node interface is enforced only by Relay.js, everywhere else it's optional. You don't have to use it, but if you're building an app that will grow in the future, Node might make it easier to scale.

If this is your first app and it does not have a complex schema, you can skip nodes and edges.