Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Tim Hanlon
    @timhnln_twitter

    I'm generating error messages for the front end like this:

    create or replace function app_public.register_person(
      handle text,
      display_name text,
      email text,
      password text
    ) returns app_public.person as $$
    declare
      person app_public.person;
      constraint_name text;
    begin
      insert into app_public.person (handle, display_name) values
        (handle, display_name)
        returning * into person;
    
      insert into app_private.person_account (person_id, email, password_hash) values
        (person.id, email, crypt(password, gen_salt('bf')));
    
      return person;
    
    exception 
      when check_violation then
        get stacked diagnostics constraint_name = CONSTRAINT_NAME;
        if constraint_name = 'handle_length' then
          raise exception 'Your handle is too long';
        end if;
      when unique_violation then
        get stacked diagnostics constraint_name = CONSTRAINT_NAME;
        if constraint_name = 'person_account_email_key' then
          raise exception 'That email is already in use';
        elsif constraint_name = 'person_handle_key' then
          raise exception 'That handle is already in use';
        else
          raise exception '%', constraint_name;
        end if;
    end;
    $$ language plpgsql strict security definer;

    It works, but I'm curious as to whether this is the "right" approach or not.

    Frank Sheiness
    @syndesis
    if it's for the front end, i'd put the length check there
    Tim Hanlon
    @timhnln_twitter
    There will be a length check on the front end, but this is my "never trust the client" implementation
    Benjie Gillam
    @benjie
    Tim: that looks alright (from the tiny window I can see but not scroll on mobile) but you might prefer to use handleErrors to group these together in one central location.
    Sam Levin
    @samlevin
    Hi @benjie, just wanted to pop in and say that this project, your handling of it, the docs, support, and community is awesome all around. Postgraphile is a powerful, idomatic, and elegant tool. I may start using it for customer projects and if so, would eventually like to dive into the internals and maybe contribute a bit. Thanks for your efforts on this. Just learned a lot about my own use cases through reading a bunch of your answers in github issues
    Benjie Gillam
    @benjie
    I really need to turn those GitHub issue comments into docs! Thanks for your kind words, they are much appreciated 🙏
    Benjie Gillam
    @benjie
    Contribution to the core would be welcome also; the API is pretty much fixed now so I think the thing that needs the most work is graphile-utils to make plugin factories to make doing things a lot easier for people. For example, there really should be an inflector plugin factory that enables you to override the inflector. Anyway I'm getting ahead of myself.
    Alexey Yurchenko
    @alexesDev
    Hello. Why *Connection types not marked as not null?
    And why nodes: [Move]! node item not marked as not null? [Move!]!
    flow types from schema (relay) are optional and I have many errors like this:
    Cannot get allProducts.nodes because property nodes is missing in null or undefined [1].
    Benjie Gillam
    @benjie
    Use --no-setof-functions-contain-nulls
    Alexey Yurchenko
    @alexesDev
    @benjie thanks
    Benjie Gillam
    @benjie
    👍
    I really want a hubot in this channel so I can program a bunch of lookups like this 🙂
    Chad Furman
    @chadfurman
    How does Shopify get 80k RPS?
    Chad Furman
    @chadfurman
    Looks like lots of servers and EC2 autoscaling groups
    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: