relayjs – Adding multiple node fields in Graphql query which follows relay cursor specifications

As per graphql cursor specification,
Each connection object should have list of Edges. Each edge will have a node field.

So schema for userData query will look like this

type query {
 userData(id: string): UseConnection
}

type UseConnection {
  edges: [UserEdge!]!
  pageInfo: PageInfo
}

type UserEdge {
 node: UserNode
 cursor: String
}

type UserNode {
  id: string;
  name: string;
  ....
}

My question is, I need to have a V2 object for UserNode type. For eg. UserNodeV2

Can i just modify UserEdge type and include nodeV2 field of type UserNodeV2

type UserEdge {
 node: UserNode
 nodeV2: UserNodeV2
 cursor: String
}

This allows me to keep using same userData query and just include a new field for V2 object type. Clients can request nodeV2 object if needed while making this graphql query.

Other option is to write a completely new userDataV2 query and have V2Connection type, V2Edge and V2Node type.

I wanted to know which option will be a better practice in Graphql specifications?

Read more here: Source link