# I need help with graphQuery use

**URL:** <https://community.prismic.io/t/i-need-help-with-graphquery-use/12891>\
**Category:** Developing with Prismic\
**Tags:** nextjs, typescript, graphquery\
**Created:** [April 12, 2023, 5:44pm UTC](https://community.prismic.io/t/i-need-help-with-graphquery-use/12891 "2023-04-12T17:44:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![max.cttn](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/max.cttn/32/5789_2.png) [@max.cttn](https://community.prismic.io/u/max.cttn)\
**Post date:** [April 12, 2023, 5:44pm UTC](https://community.prismic.io/t/i-need-help-with-graphquery-use/12891/1 "2023-04-12T17:44:48Z")

</div>

Hello to all,

I'm coming to you because I'm stuck with my requests to Prismic in my NextJS application.  
I have a main request that calls my custom type `homepage` which contains all the slices on the page.

For the example I'm going to base it on the `blog` slice:  
This slice contains static information that I can retrieve.

However, I have custom posts of type `post` inside this slice that appear in `items` but do not contain the post information (see below), `post` also contains a custom type `cta`.

I realized that I needed to use `graphQuery` to access the contents of `post` and `cta`.

The hierarchy of this part of the content giving :  
`blog` ( slice ) =\> `post` ( content relationship, repeatable, custom type ) =\> `cta` ( content relationship, custom type )

For a better readability and less code I took only the query that retrieves my custom type `post` and must also retrieve the custom type `cta` inside

Note: My request works in the Prismic dashboard by testing it in: my-repo/graphql

I currently have this result:

```auto
{
    "id": "ZDQmzhAAACIADPKP",
    "type": "cta",
    "tags": [],
    "lang": "fr-fr",
    "slug": "discover-our-pms",
    "first_publication_date": "2023-04-10T15:10:14+0000",
    "last_publication_date": "2023-04-12T14:19:16+0000",
    "uid": "management",
    "link_type": "Document",
    "isBroken": false
}

```

I have this query currently:

```auto
export async function getStaticProps({ previewData }: GetStaticPropsContext) {
	const client = createClient({ previewData });

	// Query page
	const page = await client.getSingle("homepage");
	const posts = await client.getAllByType("post", {
		graphQuery: `{
		allPosts {
			edges {
				node {
					image
					icon
					title
					body
					list
					cta {
						... on Cta {
							text
							url {
								_linkType
							}
						}
					}
				}
			}
		}
	}
	`,
	});

	return {
		props: {
			page,
			posts,
		},
	};
}

```

Thank you very much for your 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:** [April 12, 2023, 7:05pm UTC](https://community.prismic.io/t/i-need-help-with-graphquery-use/12891/2 "2023-04-12T19:05:11Z")

</div>

Hey there.

You're seeing this error because you're using GraphQL instead of the GraphQuery syntax that you can use with REST queries.

Graphql is a query language for APIs and on the other hand, GraphQuery is a Prismic-specific query syntax that is used to fetch data from your repository's API. GraphQuery is similar to Graphql in that it allows you to retrieve specific data from the API but has syntax and functionality differences.

Here's a quick example of a GraphQuery:

```auto
graphQuery={
  post {
    cta {
      ...on cta {
        .text
      }
    }
  }
}

```

Check out the full documentation:

> **[GraphQuery API Option Technical Reference](https://prismic.io/docs/graphquery-rest-api)**
>
> This shows how to use the Prismic GraphQuery query option to retrieve certain fields and retrieve content from linked documents.

---

<div class="post-metadata">

**Author:** ![max.cttn](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/max.cttn/32/5789_2.png) [@max.cttn](https://community.prismic.io/u/max.cttn)\
**Post date:** [April 13, 2023, 2:03pm UTC](https://community.prismic.io/t/i-need-help-with-graphquery-use/12891/4 "2023-04-13T14:03:27Z")

</div>

Thanks a lot, indeed I confused graphql and graphquery.  
Now it works much better
