Coder Social home page Coder Social logo

Comments (9)

Zireael avatar Zireael commented on May 30, 2024

Folowing on the above, if I npm install tslib and pg, then I get the following error:
By the way, the pgmemento v0.7 doesn't seem to include function get_audit_information

with RUN npm install -g postgraphile-audit-plugin tslib pg:

no entities found to add audit fields to
A serious error occurred when building the initial schema. Exiting because `retryOnInitFail` is not set. Error details:

Error: The first argument to makeExtendSchemaPlugin must be generated by the `gql` helper, or be an array of the same.
    at /usr/local/lib/node_modules/postgraphile-audit-plugin/node_modules/graphile-utils/node8plus/makeExtendSchemaPlugin.js:21:27
    at Array.reduce (<anonymous>)
    at /usr/local/lib/node_modules/postgraphile-audit-plugin/node_modules/graphile-utils/node8plus/makeExtendSchemaPlugin.js:19:55
    at SchemaBuilder.applyHooks (/usr/local/lib/node_modules/postgraphile/node_modules/graphile-build/node8plus/SchemaBuilder.js:252:20)
    at SchemaBuilder.createBuild (/usr/local/lib/node_modules/postgraphile/node_modules/graphile-build/node8plus/SchemaBuilder.js:307:24)
    at SchemaBuilder.buildSchema (/usr/local/lib/node_modules/postgraphile/node_modules/graphile-build/node8plus/SchemaBuilder.js:321:26)
    at SchemaBuilder.watchSchema (/usr/local/lib/node_modules/postgraphile/node_modules/graphile-build/node8plus/SchemaBuilder.js:386:32)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.exports.watchPostGraphileSchema (/usr/local/lib/node_modules/postgraphile/node_modules/postgraphile-core/node8plus/index.js:252:5)
    at async createGqlSchema (/usr/local/lib/node_modules/postgraphile/build/postgraphile/postgraphile.js:67:21)  

from postgraphile-audit-plugin.

phryneas avatar phryneas commented on May 30, 2024

I'll take a look at that, it's quite possible that our build output requires tslib - I just never noticed as all our tests were done using TypeScript, which ships that library as part of it's core. Thanks for bringing that to our attention!

The second error you're getting should be because there is just nothing to audit, resulting in an empty schema extension - which the graphql parser doesn't like. Unfortunately, postgraphile offers no way to bail out of that, so it throws an error.
Currently, we're identifying auditable tables by looking for the property audit_id in the schema you specified in the options. Do you have any of those there?

By the way, the pgmemento v0.7 doesn't seem to include function get_audit_information

Yes, get_audit_information is part of the Setup.sql.
The one we are shipping contains some workarounds for pre-0.7 though - with 0.7 out it should be possible to write that a lot more performant. I'll have to look into that.

# this will ask you for a target schema and then create the `AuditEvent` type and `get_audit_information` function.
psql -h host -p 5432 -U user -d database -f Setup.sql

from postgraphile-audit-plugin.

Zireael avatar Zireael commented on May 30, 2024

Thanks for your replies, i'll have a look to see if I've got something I can fix on my end. Few things I can clarify:

The pgmemento docs have now different name for the default audit_id column ('pgmemento_audit_id'):
https://github.com/pgMemento/pgMemento/wiki/Initialize-auditing
And I used their init function example and ended up with 'audit_trail_id', which get's put into the schema as auditTrailId, I guess (I'm using simple inflections plugin and few other goodies to beef up the stack). Could you add a key in .postgraphilerc.js to customise the name of the audit column the audit plugin expects?

Current setup.sql doesn't seem to have get_audit_information, at least not in the source code. I was having trouble installing pgmemento in my docker environment, so just executed the *.sql files against my database and initialised by hand. There were few duds in their wiki that tripped me (names of some function parameters were wrong etc). It's possible pgmemento introduced breaking changes to their code since you've last looked without bumping into major version (and documenting them.). I looked at my list of functions in the schema and the get_audit_information wasn't there.

I've pasted you consents of my dockerfile and docker-compose - should be enough to see the build for yourselves.

What do you think?

from postgraphile-audit-plugin.

phryneas avatar phryneas commented on May 30, 2024

I'll take a look at the naming stuff. We're internally still using a very-soon-before-the-0.7-release snapshot, so I might have missed that renaming.

Meanwhile:
I'm not referring to pgMemento's Setup.sql, but to our Setup.sql ;)

from postgraphile-audit-plugin.

Zireael avatar Zireael commented on May 30, 2024

Meanwhile:
I'm not referring to pgMemento's Setup.sql, but to our Setup.sql ;)

Ah, then something went horribly wrong because that function didn't get added to my database Q.Q

from postgraphile-audit-plugin.

phryneas avatar phryneas commented on May 30, 2024

You have to execute that file by hand during the installation - we won't mess around in your database without your consent ;)

from postgraphile-audit-plugin.

phryneas avatar phryneas commented on May 30, 2024

But yeah, we could make that a lot more obvious in our readme.

from postgraphile-audit-plugin.

Zireael avatar Zireael commented on May 30, 2024

But yeah, we could make that a lot more obvious in our readme.

I've missed that one then. Was the text glowing red with lots of emoticons sprinkled all over?

This line from readme tripped me:

The plugin comes preconfigured out of the box. It can be configured using a .postgraphilerc.js:

Thanks for the tip, I'll revisit more carefully now ^^

from postgraphile-audit-plugin.

phryneas avatar phryneas commented on May 30, 2024

Sorry this took a while, but I just released a version with support for pgmemento_audit_id (it's completely configurable) and an update get_audit_information function in Setup.sql which should be a lot more performant.

from postgraphile-audit-plugin.

Related Issues (2)

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.