apollo – Identify lineage of all Scalar types in a GraphQL schema
I have a large GraphQL schema containing scalar
, object
and enum
types.
I want to print this in a format such that the hierarchy from all Object nodes to Scalar nodes is shown. My overall objective is find all leaf nodes of a particular scalar type (along with their lineage); for example String
.
To better illustrate with an example. For the following schema:
type Book {
title: String
author: Author
}
type Author {
name: String
books: [Book]
}
I’d like to print something similar to:
Book.title [String]
Book.author.name [String]
Author.name [String]
Author.[books].name [String]
I am new to GraphQL and possibly asking a very naive question, but want to know if there is a simple way to solve it? I have seen this, but it doesn’t really solve my problem and it seems I’ll have to write the traversal (of tree) on top of this.
Read more here: Source link