GetNodeFromUri
Using the WP types/models alongside fragments. the query will only return the fragment that equals the __typename.
# uri - "/thoughts/author/themedemos/" == User ...query GetNodeFromUri($uri: String!) { nodeByUri(uri: $uri) { __typename ...ContentType ...Page ...Post ...Category # this will be the returned value given above uri ...User }}
fragment User on User { email name}
fragment Category on Category { name description posts { nodes { id title content link uri author { node { name avatar { url } } } date commentCount categories { nodes { name link uri } } } }}
fragment Page on Page { title content commentCount comments { nodes { id date author { node { name ... on User { avatar { url } } } } content } }}fragment Post on Post { title content commentCount comments { nodes { id date author { node { name ... on User { avatar { url } } } } content } }}
fragment ContentType on ContentType { name contentNodes { nodes { id ... on Post { title content date author { node { id name avatar { url } } } categories { nodes { name } } } } }}