Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    But reset is strictly more correct and accurate
    Personally I use transactions and set local; then when transaction finishes everything is cleared
    matrixbot
    @matrixbot
    Nolan Thanks.
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    Hi everyone! I have this question, Can I have PostGraphile over AWS Lambda? if that is so, can you guys share with me info about it. Thanks
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    AWS Lambda it’s ok for PostGraphile ? Or is there a better way to deploy PostGraphile to AWS Cloud?
    Benjie Gillam
    @benjie
    Deploy it any way you’d deploy a Node.js Express app; personally I use Heroku for most things. PostGraphile will run on Lambda but it’s not optimised for that environment and it loses the concurrency benefits PostGraphile has. https://github.com/graphile/postgraphile-lambda-example
    Aprendo Aprendo Aprendo Aprendo Aprendo.....
    @bichoraroTV_twitter
    What about fargate of AWS? https://aws.amazon.com/fargate/
    matrixbot
    @matrixbot
    Nolan Having some trouble porting my first update mutation to postgraphile. https://pastebin.com/hu7virAn That's with DEBUG set to postgraphile:graphql,postgraphile:postgres,postgraphile:postgres:error. Looks like there's no query, and the result of updateOrder is null.
    Nolan My id field is a uuid, wondering if the parameter in the mutation is off since it's ID! but nothing else in the stack reports a type mismatch. Happy to provide additional debugging details.
    Benjie Gillam
    @benjie
    Perhaps you mean to use “updateOrderById” mutation instead? The one you’re using is designed for the nodeId field (hence ID as you mentioned)
    matrixbot
    @matrixbot
    Nolan Ay, that did it. Thanks!
    Benjie Gillam
    @benjie
    Yw. Today I saw the skeleton of a T.rex. Impressive creatures! They 3D printed its missing leg which was p cool.
    eliecerthoms
    @eliecerthoms
    Awesome
    Hey @benjie, any idea why this "set-returning functions must appear at top level of FROM", would happen?
     postgraphile:postgres begin +22s
      postgraphile:postgres select set_config($1, $2, true), set_config($3, $4, true) +2ms
      postgraphile:postgres with __local_0__ as (
      postgraphile:postgres       select to_json(__local_1__.__local_1__) as "value"
      postgraphile:postgres       from unnest("crtrs"."get_notifications_alt"()) as __local_1__
      postgraphile:postgres
      postgraphile:postgres       where (TRUE) and (TRUE)
      postgraphile:postgres
      postgraphile:postgres
      postgraphile:postgres
      postgraphile:postgres     ), __local_2__ as (select json_agg(to_json(__local_0__)) as data from __local_0__) select coalesce((select __local_2__.data from __local_2__), '[]'::json) as "data"  +2ms
      postgraphile:postgres:error error: set-returning functions must appear at top level of FROM
    this is a more complete error
    Benjie Gillam
    @benjie
    I can’t read that on mobile 😔
    I’m guessing you’re using does “select my_func(..)” instead of “select * from my_func(..)”
    eliecerthoms
    @eliecerthoms
    https://pastebin.com/Mv9b7wK2 here's the function if it helps
    when I do select * from crtrs.get_notifications_alt(); on my ide, it works ok
    Any way I could force postgraphile to select it like that?
    If not I could just make a separate api endpoint no problem
    And I have no rush, if you can look on it when you have the time I'd appreciate it a lot
    Benjie Gillam
    @benjie
    Ah we don’t support combining setof with arrays; sorry this restriction isn’t documented; it’s effectively because arrays in pg are not so strongly typed (they can change dimensionality/etc) and also because we use unnest which goes deep rather than just one level (I think)
    If you need that wrap it in a custom composite type and return setof that.
    “Connection (list) of arrays (lists) of json” seems a weird thing to want; perhaps use json_aggregate instead and have the json itself be the array?
    eliecerthoms
    @eliecerthoms
    Alright! Thanks!
    Benjie Gillam
    @benjie
    Np
    Nathan Aherne
    @nathanaherne
    I am trying to create a computed column that creates the column by pulling it from from a different table. I don't seem to be having an success and therefore I think it may not be possible to do this, can someone confirm if this is possible or not please? See code below.
    create or replace function admin.event_startdatetime(event admin.event)
    returns timestamp as $$
      select
      event_start_datetime.event_start_datetime
      from 
      admin.event
      left join
        (select
        admin.event_date_time.event_id,
        min(to_timestamp(EXTRACT(EPOCH FROM (min(admin.event_date_time.event_date) || ' ' || min(admin.event_date_time.start_time))::timestamp))::timestamp) over (partition by admin.event_date_time.event_id) as event_start_datetime
        from 
        admin.event_date_time
        group by
        admin.event_date_time.event_id
        ) as event_start_datetime
      on event.id = event_start_datetime.event_id;
    $$ language sql stable security definer;
    
    comment on function admin.event_startdatetime(admin.event) is 'Get the start date/time of each event - computed column on admin.events table';
    The function works fine but I am not getting the computed column in GraphQL
    Benjie Gillam
    @benjie
    Odd. Yes it should definitely work. I can’t immediately see an issue with the function; is admin in the list of schemas PostGraphile is using?
    Are you using no-ignore-rbac? If so, check you’ve granted execute on the function.
    Functions are a black box to PostGraphile; we only see what’s in the declaration, not the body.
    james-s-turner
    @james-s-turner

    Just written my first query and was wondering where the 'condition' syntax comes from. e.g.

      allBoatClasses (condition: {id: 1} ) {
        edges  {
          node {
            id
            name
          }
        }
      }
    }

    I can't find any reference to 'condition' in GraphQL docs. Is it specific to Postgraphile?

    Benjie Gillam
    @benjie
    Yes
    There’s a filter plugin you might want to check out also, it’s much more powerful, but you should understand the risks (see the README) before using it.
    Michael Kelly
    @mkellyclare
    Hi @benjie, great project, was trying it out and wondering if there is any way for the generated enum types to be lowercase. Have some existing code and types that are lowercase and wondering if there is any way to match them. Thanks
    More later; but try follow what that plugin does but for enums.
    Michael Kelly
    @mkellyclare
    Thanks! I'll give that a go.
    matrixbot
    @matrixbot
    Nolan Is it possible to define a RLS policy such that queries in with clauses run outside of RLS checks? I have an order table, and an attempt table tracking attempts on those orders. I have RLS policies blocking which attempts people who fulfill the orders can see, but now I want a policy that shows orders without any attempts. Problem is, just because a given role can't see an attempt doesn't mean one doesn't exist.
    Nolan So right now the RLS policy limiting what attempts someone can see kicks in. Then I have another RLS policy on orders that only shows any for which attempts don't currently exist, but if someone can't see the attempt then this check returns true and just shows everything.
    Benjie Gillam
    @benjie
    @mkellyclare Here's the plugin (11 lines of code, mostly boilerplate) that makes the enums into capitals in PostGraphile. Probably the easiest thing to do is to write another plugin of your own that changes them back lower case again. https://github.com/graphile/graphile-build/blob/69d7b1cbe48ea5f50e3121916e7b1e12d1c70008/packages/postgraphile-core/src/index.js#L87-L97
    matrixbot
    @matrixbot
    Nolan OK, think I figured it out. Moved the logic into a security definer function.
    Benjie Gillam
    @benjie
    Nolan / @matrixbot : RLS policies themselves obey RLS, this is generally what you want but sometimes it isn't - when it's not you can use a SECURITY DEFINER function to bypass RLS (and RBAC) and perform whatever checks you need.
    e.g. I commonly do something like CREATE POLICY select_admins ON topics FOR select USING (organization_id = any(current_user_admin_organization_ids()));
    This is very efficient (much more so than a join) because it only needs to look up the organization IDs once, and then it can use an index check on that.
    Ah. Thats what you did. Sorry; still catching up!
    matrixbot
    @matrixbot
    Nolan Got it. And just to confirm what I suspect, RLS policies can't block updates to specific columns, right? I.e. if I have an accepted field on attempt that everyone can see but only the recipient of the attempt can change, I should probably just define a custom mutation and @omit the field from the generated update mutation?