Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    @chadfurman great docs and videos thanks for sharing!!!
    Chad Furman
    @chadfurman
    You are very welcome. Thanks to @benjie for making GraphQL something I can use on my project in a robust way with minimal effort. 500-1500 requests per second on a single server is pretty awesome
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    👊👍
    Benjie Gillam
    @benjie
    😁 Thanks Chad! I’m going to retweet your tweet later today (trying to optimise for impact)
    Benjie Gillam
    @benjie
    I'm back from holidays; RC3 is now @latest rather than @next 👍
    Andreas Hubel
    @saerdnaer
    Hi, Anyone recommendations regarding graphile/graphile-build#267 ?
    Benjie Gillam
    @benjie
    @saerdnaer Did the plugin suggestion work?
    Andreas Hubel
    @saerdnaer
    I will try it tomorrow.
    Benjie Gillam
    @benjie
    @/all If you're able to write a short 1/2 sentence testimonial for me to put on the Graphile site that would be super-awesome.
    Also I'm doing the Reactiflux Q&A tonight if anyone's interested.
    Alexey Yurchenko
    @alexesDev
    Hi. I see @isImportant tag... but how I can mark a field as not important?
    Benjie Gillam
    @benjie
    @isImportant doesn't do anything. You can add @isUnimportant I guess.
    There's not many tags that are currently implemented; the infrastructures there in case you want to use it in a plugin (or in case we use it in future functionality).
    Alexey Yurchenko
    @alexesDev
    I solved my problem with @omit. Thanks.
    comment on column stock.shop_order_items.move_id is '@omit';
    Benjie Gillam
    @benjie
    Cool 👍 You can also choose to omit only in certain situations. It's also looking at using --no-ignore-rbac / ignoreRBAC: false so that we automatically exclude things that don't have permissions granted.
    Jem
    @jemgillam
    Benjie is doing a Postgraphile Q&A session over on Reactiflux right now, come join us https://www.reactiflux.com/
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    mutation {
      updateUserByUserId(input: {userId: "de5f6a1e-58ad-4c54-ab51-55fbca17ba55", userPatch: {address: ""}}) {
        user {
          userId
          name
          address
        }
      }
    }
    Return
    {
      "errors": [
        {
          "message": "cannot extract elements from a scalar",
          "locations": [
            {
              "line": 2,
              "column": 3
            }
          ],
          "path": [
            "updateUserByUserId"
          ]
        }
      ],
      "data": {
        "updateUserByUserId": null
      }
    }
    address it is a jsonb type
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    Why that happen?
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    It is the latest version
    Benjie Gillam
    @benjie
    Aprendo; please file that with reproduction instructions/SQL file. I’ve never seen PostGraphile make that error before. BTW have you tried restarting your server?
    K. Golbang
    @jepetko
    hello there
    I have a question regarding the aggregation functions (COUNT, AVG, ...).
    are they supported by postgraphile?
    Benjie Gillam
    @benjie
    We have count via totalCount; the others can be added via plugins but we don't have any official plugins for that yet. I'm planning on adding them at some point in a similar way to computed columns, but using aggregate functions instead. You can also write custom queries or computed columns that do this; for example I just wrote this one:
    create function XXX_public."items_checklistItemCompletedCount"(i XXX_public.items) returns int as $$
      select coalesce(
        (select count(*)::int from XXX_public.items where "rootPostId" = i.id AND type = 'CHECKLIST_ITEM' and completed is true),
        0
      ) where i.type = 'POST';
    $$ language sql stable;
    This adds the field checklistItemCompletedCount to the Item type which does a count. You could replace the count with any aggregate function you like.
    K. Golbang
    @jepetko
    okay, this is just what I expected. thank you very much!
    Benjie Gillam
    @benjie
    Let me know what you want to achieve and I can probably recommend a good way of doing it 👍
    K. Golbang
    @jepetko
    hi, I create the function just like any other computed column function but now I have couple of questions.
    what my function looks like:

    CREATE TYPE geo.grouped_value AS (value bigint, label text);

    CREATE OR REPLACE FUNCTION geo.planet_osm_polygon_branchesCount(i geo.planet_osm_polygon) RETURNS setof geo.grouped_value AS

    KaTeX parse error: Expected 'EOF', got '&' at position 88: WHERE poi.way &̲& i.way GROUP : 
      SELECT COUNT(*) AS value, shop as label FROM geo.planet_osm_point poi WHERE poi.way && i.way GROUP BY shop ORDER BY COUNT(*) DESC;
    
    LANGUAGE SQL STABLE;

    oops

    `CREATE TYPE geo.grouped_value AS (value bigint, label text);

    CREATE OR REPLACE FUNCTION geo.planet_osm_polygon_branchesCount(i geo.planet_osm_polygon) RETURNS setof geo.grouped_value AS

    KaTeX parse error: Expected 'EOF', got '&' at position 88: WHERE poi.way &̲& i.way GROUP : 
      SELECT COUNT(*) AS value, shop as label FROM geo.planet_osm_point poi WHERE poi.way && i.way GROUP BY shop ORDER BY COUNT(*) DESC;
    
    LANGUAGE SQL STABLE;`

    CREATE TYPE geo.grouped_value AS (value bigint, label text);
    
    CREATE OR REPLACE FUNCTION geo.planet_osm_polygon_branchesCount(i geo.planet_osm_polygon) RETURNS setof geo.grouped_value AS $$
      SELECT COUNT(*) AS value, shop as label FROM geo.planet_osm_point poi WHERE poi.way && i.way GROUP BY shop ORDER BY COUNT(*) DESC;
    $$ LANGUAGE SQL STABLE;
    now...
    :-)
    so basically I'm working with geo data from OSM. The query looks like this:
    query {
    
      allPlanetOsmPolygons(
        filter: {
          adminLevel: {
            equalTo: "4"
          },
          name: {
            equalTo: "Wien"
          }
        }
      ) {
        edges {
          node {
            osmId
            name,
            branchescount {
              edges {
                node {
                  value
                  label
                }
              }
            }
          }
        }
      }
    }
    the questions are: 1) does postgraphile perform the filter first BEFORE branchesCount gets executed? That means is branchesCount executed on an limited Recordset (equalTo: "4" ...)?
    2) is it possible to filter on the returned branchesCount set? The returned data is like follows:
    K. Golbang
    @jepetko
    {
      "data": {
        "allPlanetOsmPolygons": {
          "edges": [
            {
              "node": {
                "osmId": "-109166",
                "name": "Wien",
                "branchescount": {
                  "edges": [
                    {
                      "node": {
                        "value": "744",
                        "label": "supermarket"
                      }
                    },
                    {
                      "node": {
                        "value": "714",
                        "label": "clothes"
                      }
                    }
                 ]
                }
              }
            }
          ]
        }
      }
    }
    Benjie Gillam
    @benjie
    1; yes - you can think of it working in the same way as standard GraphQL (although it technically doesn't!) - i.e. each parent GraphQL field is resolved before the children are - so the filter is executed and the nodes produced before the branchescount can execute.
    K. Golbang
    @jepetko
    what if I were interested in supermarkets only? What would the query look like?
    ad 1): perfekt
    Benjie Gillam
    @benjie
    By the way wrap your function name in double quotes to retain the capital: CREATE OR REPLACE FUNCTION geo."planet_osm_polygon_branchesCount"(i geo.planet_osm_polygon) (alternatively use underscores)
    2: yes: your computed column can accept additional arguments and those are exposed to GraphQL
    e.g. you could have node { branchesCount(label: "supermarket") } or similar.
    via CREATE OR REPLACE FUNCTION geo.planet_osm_polygon_branchesCount(i geo.planet_osm_polygon, label text) RETURNS ...
    K. Golbang
    @jepetko
    ad 2): perfekt. thank you
    Benjie Gillam
    @benjie
    This is lacking in the docs actually; thanks for pointing it out. cc @jemgillam https://www.graphile.org/postgraphile/computed-columns/