hello ,
is it possible to get only title and slug from page doc.
With the REST endpoints, there is currently not a way to say what specific fields you want returned. Sounds like you may want to explore using the GraphQL endpoints. This is standard with GraphQL.
@denolfe can you share me reference.
Also, you should be able to open
http://localhost:3000/api/graphql-playgroundon most payload projects to play around with the API calls.
A query would look something like this:
query {
allPosts {
title
slug
}
}
hello @denolfe for execute graphql query need any other configuration?
Everything should work out of the box
okay i'll try thanks @denolfe for quick response.
i'm getting error
You'll want to use GraphQL's completion to aid in your queries
ok @denolfe got it.
hello @denolfe i need help for execute graphql query.
can you tell me what exactly need for it.
This is a bit vague of a request. What are you having trouble with specifically? Payload's GraphQL endpoint is just like any other GraphQL endpoint. If you need help forming queries, I'd suggest heading over to the GraphQL site to learn the basics. If you have something that is Payload-specific, happy to help.
Examples of queries can be seen in our Website repo here:
https://github.com/payloadcms/website/tree/main/src/graphql@bhavikak I can see from the screenshot graphql is having trouble with some of your config. Enums are specifically used in
select
and
radio
field types. Instead of
true
or
false
you will have to use
1
,
'true'
, or
0
,
null
or
'false'
to represent true/false instead of a boolean.
hello @dribbens i fixed it but i got another error.
@denolfe my query don't work in graphql playground. so i thought i missed some configuration or anything else so that's why i'm asking.
manage_category is a global config and it's my custom component.
What do you have configured for that field? I don't need the component code.
i call rest api and render data into table
There is something in your field that is causing a problem with the GraphQL generation
What is the type?
What other properties do you have in that field?
It sounds like a group with no fields by the error I'm guessing but that isn't valid for payload and should throw an error on start
Just paste the config here and I can better understand
your guess is right.
but don't know what's the issue. in config.
A global with no fields seems to be your issue.
What are you trying to do with that exactly?
It won't be useful without any fields
We don't validate the config to prevent that but we probably should.
i'm just calling api and render data into table.
and for render data in tabular format i use a third-party package.
Can you remove manage categories from your globals? I don't see how it could be doing anything
That should fix the issue with GraphQL on your project.
but i need that custom component
I see. Well the workaround then is that you give it some silly placeholder field to satisfy GraphQL. The field itself doesn't matter, but that empty
fields
array is definitely your issue.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.