agentejo / cockpitql Goto Github PK
View Code? Open in Web Editor NEWGraphQL addon for Cockpit CMS - https://github.com/agentejo/cockpit
GraphQL addon for Cockpit CMS - https://github.com/agentejo/cockpit
Using the GraphQL plugin, the only result I get is this error:
Please implement the index action
Do you have any idea from where this come from? I'm using Cockpit from Github (so the latest version) and the latest version of the plugin.
Firstly, thanks for the updates of this addon.
I can use mutation in playground from cockpit dashboard.
But I can't use it from frontend apps or tools. It only shows me "Unauthorized".
This is example from Altair GraphQL Client
I set the API key's rule to *
and open for public including (edit, delete) but still it always return "Unauthorized"
I guess there is something wrong with mutation with authentication.
We currently have some dynamically generated queries for collections. Example: if we have a collection named members
, the following query is valid:
{
allMembers {
_id
}
}
If we want to get the data from a singleton, the only possible way right now is to do a query like follow:
{
singleton(name: "singletonname")
}
However, we lose the ability to filter the response, graphQL-syle.
Dynamic queries for singletons should also be generated. E.g.: if we have a singleton named footer
, the following query would be valid:
{
footer {
...
}
}
If you query with a lang parameter and there is a collection link, the collection link item will show up in the default language. We should be able to specify the lang on any field that returns a xyzCollectionLink type.
How do I install this?
There's literally no instructions on how to install addons anywhere here or in the cockpit docs.
This is painful.
{
allPerson {
name
image {
url
}
}
}
It returns url
as null
. It seems like linked items only return _id
Wondering how it will be possible with CockpitQL to query the "Cockpit" namespace api methods such as listUsers ("/api/cockpit/listUsers"). What I'm looking to be able to do is retrieve a list of user records or single user record through CockpitQL but have not identified how to do it. Is it possible?
Thanks
I've installed cockpit and CockpitQL (git clone to addons folder).
But I cannot access API. I've always get:
{"error":"Unauthorized"}
In logs there isn't any information, and I'm using Full access API-key
. Should I do something additional?
That is the only response i get from /api/graphql , no matter what i do. The error doesn't get more specific. Any clues, what this means?
I use the cockpit:next and this addon. Nothing fancy.
Can i have more debug messages somewhere to find the error?
Repro Steps:
Expected results:
Supplying variables should not cause the application to error when sending them in a query parameter
The codebase suggess that the lang parameter is only effective when the _id parameter is defined as well. However, it seems that when we query a collection with the _id parameter, the server crash.
query AQuery {
cockpit {
collection(name: "ACollectionName", _id:"AnId")
}
}
The result is:
{
"errors": [
{
"message": "Internal server error",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"cockpit",
"collection"
]
}
],
"data": {
"cockpit": {
"collection": null
}
}
}
Fatal error: Uncaught Error: Call to a member function on() on null in E:\phpStudy\PHPTutorial\WWW\api.php:10 Stack trace: #0 E:\phpStudy\PHPTutorial\WWW\bootstrap.php(309): include() #1 E:\phpStudy\PHPTutorial\WWW\index.php(22): require('E:\\phpStudy\\PHP...') #2 {main} thrown in E:\phpStudy\PHPTutorial\WWW\api.php on line 10
Is it actually possible to filter by query variables?
query post($id: String) {
allPosts(filter: {_id: $id}) {
title
__typename
}
}
{
"id": "5c69be76387945700280002a4"
}
I always get an empty array:
{
"data": {
"allPosts": []
}
}
even though apollo-client-dev-tools is showing me the variable
query post{
allPosts(filter: {_id: "5c69be76387945700280002a4"}) {
title
__typename
}
}
works fine.
Thanks!
i am trying to get a field that type is object but i get an error message
{
allPosts(filter:{published:true}){
_id,
title
content
image{
path
}
config{
children
}
}
}
Error message
Cannot query field "config" on type "posts".
How can i get my object ?
Hi, i'm testing this module and i can query in my collections just like i do in traditional REST cockpit API, but i want to use some cool graphql features like query in collection and get only the fields that i need, how can i do this with this module?
I've gone through the link https://github.com/agentejo/CockpitQL
I'm not sure where to place the GraphQL folder and what to modify in my cockpit project.
It seems that the token
parameter is always needed when getting data. Even if the requested data has public visibility.
I am trying to get latest posts from my collection, but want only to fetch those that are published until this day today. So I want to know how to fetch posts that are released at dates prior till today.
I tried to use the suggestion from this issue, but it doesn't seem to work neither as the $
-sign is not accepted in GraphQL as a key.
{
collection(name:"posts", filter:{published: true, date:{$lt: "2019-03-01"}})
}
While working on my project, I was faced with the need to make one of the parameters a float. Unfortunately, I found out that this is not provided in the addon, which forces me to use the string field in GraphQL.
I manually added a placeholder check, but I would like to know: will this be provided in the future?
Let's consider I have a collection of blog posts called posts
. Then I will have access to a GraphQL command called allPosts
. This works perfectly fine except when dealing with slugs generated by the text fields with option "slug": true
. It is indeed possible to filter using slug
but you can't return the slug value as an argument in the gql request.
{
allPosts(filter: { published: true, title_slug:"banana-test"}) {
title
main_image {
path
}
category
content
}
}
This works perfectly fine. but if I add the title_slug
to the variables I want returned, I get following message:
"Cannot query field \"title_slug\" on type \"posts\". Did you mean \"title\"?"
As a workaround I just reuse the same variable as I used to request the data with, but let's say you have assigned an author to the post, and need the slug of their name to link to all their posts e.g.
{
allPosts(populate: 1, filter: { published: true, title_slug:"banana-test"}) {
title
main_image {
path
}
category
content
writer {
name
name_slug
}
}
}
This won't be possible neither. But if I request the author details separately in a collections request i.e. { collection(name:"writers", filter: {_id: xxxxxxxxxxxxx}) }
then I do indeed receive the slug value as part of the entire returned JSON object. I just wished I could return this as part of the nested request as above example.
I use the BetterSlugs-Addon but the field created by it can not be queried with this addon. Is there a special way to populate the CockpitQL with those new fields as well? Thanks
When trying to install the addon via the CLI (like described in the Readme), it is not working correctly: There's just always an error when trying to call the api or open the playground.
The reason is very likely that the installation via the script creates a folder named "CockpitQl" instead of "CockpitQL".
After renaming the addon works correctly. Just in case anyone runs into the same problem...
I try to filter collection by tags fieldtype, but as a result I always see empty array. I tried to use code below with few other variants, but no success.
{
collection(name:"posts", filter:{published:true, tags:"news"})
}
I am new to Cockpit and I want to use this plugin in Gatsby.
please provide me with series of steps or a small example in order for me to use this plugin properly.
for example where to use
/api/graphql?token=*apitoken*
where to put these
{
region(name:"test"),
collection(name:"posts", filter:{published:true})
}
{
allPosts(filter:{published:true}){
_id,
title
content,
image{
path
}
}
}
should I upload this to my addon folder , and so on ...
I want to get collection called posts
and region called posts_header
. I try to do it using fetch()
function but I keep having error posted below.
Request:
fetch(`/api/graphql?token=${token}`, {
body: "query { allPosts { _id, title, content } }",
method: "POST"
})
Response:
{
"errors": [
{
"message": "Syntax Error GraphQL (1:2) Expected Name, found }\n\n1: {}\n ^\n",
"category": "graphql",
"locations": [
{
"line": 1,
"column": 2
}
]
}
]
}
Thank you for this awesome addon.
Is there a way to use GraphQL mutations with it ?
How can I filter via a linked item?
I have a BlogPost collection that links to BlogAuthor:
BlogPost {
author {
name
}
}
I would like to submit a query that's similar to:
collection(name: "BlogPosts", filter: {author: {name: "Melissa"}}, populate: 1, sort: {publicationDate: -1})
, but I get an empty collection?
Is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.