Giter Site home page Giter Site logo

cockpitql's People

Contributors

aheinze avatar fedetibaldo avatar ionicube avatar orthotypos avatar pedromdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cockpitql's Issues

GraphQL mutations

Thank you for this awesome addon.
Is there a way to use GraphQL mutations with it ?

Mutation with token

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
Screen Shot 2019-11-04 at 9 02 47 AM

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.

How to query only fields that i need?

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?

No matter what i post to the api-endpoint: Internal Error

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?

Syntax Error GraphQL (1:2)

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
        }
      ]
    }
  ]
}

Filter by query variable

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!

Fatal error: Uncaught Error: Call to a member function on() on null in

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

{"error":"Unauthorized"} all the time

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?

Lang variable does not propagate to collection links

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.

Accessing slug variables

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.

How does the lang attribute works ?

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
    }
  }
}

Dynamic singleton queries

Current

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.

Expected

Dynamic queries for singletons should also be generated. E.g.: if we have a singleton named footer, the following query would be valid:

{
  footer {
      ...
   }
}

Query API Cockpit Methods

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

Filter by tags

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"})
}

all{Collection} not being returned in __schema

When we create a new collection (e.g.: members) a new query named all${collectionPlural} (e.g.L allMembers) is generated.

However, this new query is not returned in the __schema for introspection.

screenshot 2019-02-27 at 15 05 43

This makes developer tools not being aware of this query

screenshot 2019-02-27 at 14 33 18

Filter by a linked item?

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?

Linked item does not work

{
  allPerson {
    name
    image {
      url
    }
  }
}

It returns url as null. It seems like linked items only return _id

Filter by date

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"}})
}

Error: "Please implement the index action"

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.

Using the Cockpit CLI for installation is not working

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...

Specifying variables object in query param results in 500 error

Repro Steps:

  1. Send a GET request to /cockpit/api/graphql/query specifying valid gql "query" parameter per specification at: https://graphql.org/learn/serving-over-http/
  2. Note that the query is parsed correctly, and response is sent as expected.
  3. Send another GET request, this time adding the additional "variables" query parmeter in JSON-encoded format (e.g. "{}").
  4. Note that a 500 error response is sent.

Expected results:
Supplying variables should not cause the application to error when sending them in a query parameter

Float field type would be nice to add

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?

How to use this plugin

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 ...

Error message try to get Object type

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 ?

Respect cockpit permissions

Current

It seems that the token parameter is always needed when getting data. Even if the requested data has public visibility.

Expected

  1. The token is only required when needed. If all the queries have public visibility, then the token is not required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.