# Clarification on typing data returned from GraphQuery

**URL:** <https://community.prismic.io/t/clarification-on-typing-data-returned-from-graphquery/12615>\
**Category:** Developing with Prismic\
**Tags:** nextjs, typescript\
**Created:** [March 7, 2023, 1:01am UTC](https://community.prismic.io/t/clarification-on-typing-data-returned-from-graphquery/12615 "2023-03-07T01:01:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crcollver](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/crcollver/32/5626_2.png) [@crcollver](https://community.prismic.io/u/crcollver)\
**Post date:** [March 7, 2023, 1:01am UTC](https://community.prismic.io/t/clarification-on-typing-data-returned-from-graphquery/12615/1 "2023-03-07T01:01:40Z")

</div>

Hi all,

I've been slowly converting a NextJS application to Typescript, and came across something I wasn't sure how to type properly.

While using the GraphQuery option, I'm trying to select only specific properties on my custom type. How can I reflect this in the type I return?

For instance in this query:

```auto
const posts = await client.getAllByType("blog_post", {
		graphQuery: `
			{
				blog_post{
					thumbnail_icon
					session_thumbnail
					blog_title
				}
			}
		`
	});

```

How would you ensure that only those three properties are available to the page?

I've read through the docs for NextJS and Typescript, and it looks like the [Content Relationship section](https://prismic.io/docs/typescript-nextjs#typing-content-relationships) has something similar to what I'm after but not quite.

I know this is more of a Typescript question than a Prismic question, but maybe there's some type of helper in Prismic that I'm unaware of!

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [March 7, 2023, 6:53pm UTC](https://community.prismic.io/t/clarification-on-typing-data-returned-from-graphquery/12615/2 "2023-03-07T18:53:32Z")

</div>

Hey @crcollver, [here's a similar topic that maybe answers your question](https://community.prismic.io/t/how-do-i-typing-document-with-fetchlinks/10344/4). If you are using `prismic-ts-codegen` to generate types it's not supporting fetchLinks/GraphQuery yet, so I think you need to manually write the types.

> [@How do I typing Document with fetchLinks?](https://community.prismic.io/t/how-do-i-typing-document-with-fetchlinks/10344/12):
>
> Hey @miyazato @Fares I ran into this problem and I solved it. For context, I am also using prismic-ts-codegen and a GraphQuery. I looked at the isFilled.contentRelationship and noticed it accepted some generic type arguments, and this is working for me: // contentRelationship: \<TypeEnum, LangEnum, DataInterface\> if (isFilled.contentRelationship\<'blog-author', string, BlogAuthorDocument['data']\>(doc.data.authorLink)) { doc.data.authorLink.data?.avatar; }

---

<div class="post-metadata">

**Author:** ![crcollver](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/crcollver/32/5626_2.png) [@crcollver](https://community.prismic.io/u/crcollver)\
**Post date:** [March 9, 2023, 1:37am UTC](https://community.prismic.io/t/clarification-on-typing-data-returned-from-graphquery/12615/4 "2023-03-09T01:37:16Z")

</div>

Hi @Pau, that post does help. I will probably use that approach instead of the one I linked, simply because it gives me a bit better intellisense when picking the fields I need. However, I feel like I would prefer to have the type declaration a bit closer to where I'm fetching the data.

Unfortunately, I'm a bit stumped on how to apply that to fields that are not content relationships in as clean of way as the `isFilled.contentRelationship` function. In my original example, the `thumbnail icon`, `session_thumbnail`, and `blog_title` fields are being queried because I'm trying to limit the data I get back to only what I need for the page. So, I'm looking for some sort of way to maintain the original type generated by `prismic-ts-codegen`, but just limit the fields that are on the `data` property. I think it mostly comes down to my own newness with Typescript!

I will continue experimenting, and post back if I come up with something that satisfies that.

Thank you for the help!
