Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Benjie Gillam
    @benjie
    You can, but the server will still have to evaluate most if not all the query. Better to have your function do it.
    Though I’m a bit fuzzy on this, so don’t take my word for it.
    matrixbot
    @matrixbot
    Nolan OK, I'll worry about that later. By the time we have that much data we'll have the money to justify me spending time on it. :)
    Nolan As an aside, I'm really getting into this. Just created 4 test users to start testing RLS and custom queries. I could just do it from the psql console instead of going through my app's account creation procedure, or creating bunches of associated records via raw insert statements. Nice.
    Benjie Gillam
    @benjie
    Yeah, it makes testing very fast. And of course since you know RLS is checked on all routes you only have to test each thing once rather than testing every possible route to get/infer that data
    matrixbot
    @matrixbot
    Nolan How do I set a local user_id in psql? set local user_id to 'e8bcc75c-91b5-11e8-af72-9f05955c9650'; errors, tells me user_id isn't a valid configuration parameter.
    Benjie Gillam
    @benjie
    Change it to jwt.claims.user_id or whatever
    matrixbot
    @matrixbot
    Nolan Thanks.
    Nolan Interesting, I created a custom query but didn't add any grant execute statements, and it seems to run without errors. Is it just running and returning null?
    Nolan By 'run without errors' I mean the client returns 0 errors according to the logs. Haven't looked at the network request yet.
    Benjie Gillam
    @benjie
    Functions are executable by default; you can “ALTER DEFAULT PERMISSIONS “ to change that
    Frank Sheiness
    @syndesis
    ALTER DEFAULT PRIVILEGES REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;
    Benjie Gillam
    @benjie
    👍
    matrixbot
    @matrixbot
    Nolan OK, eventually I'll be more productive at this. Getting there slowly. :)
    Nolan Happy to see RLS making my query logic cleaner, not having to tack on a bunch of where clauses based on roles in each and every query.
    Benjie Gillam
    @benjie
    Yup!
    matrixbot
    @matrixbot
    Nolan How do I unset jwt.claims.user_id once set? Tried setting it to null, syntax error.
    Benjie Gillam
    @benjie
    Empty string is one way; “reset” another
    Of course empty string doesn’t delete it. I use nullif
    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