Read Connections
tip
Install the GraphQL packages before starting this section.
In this section, we'll help you write a simple query to read a user's connections from the social graph.
- Initialize the GraphQL client:
/src/queries/GetConnections.tsx
const client = new GraphQLClient(CYBERCONNECT_ENDPOINT);
- Write a query to get the
address
anddomain
of the user’sfollowings
andfollowers
:
/src/queries/GetConnections.tsx
const GET_CONNECTIONS = gql`
query($address: String!, $first: Int) {
identity(address: $address) {
followings(first: $first) {
list {
address
domain
}
}
followers(first: $first) {
list {
address
domain
}
}
}
}
`;
Make sure to check out the full list of fields available in the CyberConnect API.
Sandbox
You can write your own query in the Playground or experiment with our code in the sandbox below!