graphile-contrib / pg-omit-archived Goto Github PK
View Code? Open in Web Editor NEWAdds soft-deletion options to PostGraphile connections. Sponsored by https://sprout.io/
License: MIT License
Adds soft-deletion options to PostGraphile connections. Sponsored by https://sprout.io/
License: MIT License
Awesome plugin, just had one small question/thing to point out.
The TS types don't seem to be available in the published package?
Could not find a declaration file for module '@graphile-contrib/pg-omit-archived'. '/home/jorlando/coding/can-courier/node_modules/@graphile-contrib/pg-omit-archived/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/graphile-contrib__pg-omit-archived` if it exists or add a new declaration (.d.ts) file containing `declare module '@graphile-contrib/pg-omit-archived';`
Is it possible to use a nullable timestamp like deleted_at
to implement a soft deletion as is customary in other frameworks? Sometimes it is useful to know when the removal occurred. In our case, we keep records of actions in the system, and the fact of deletion could be easily recorded along with the time.
@benjie mentioned on discord that it was possible to use mutliple instances of this plugin simultaneously with different configurations for different columns. Can you add docs on how to do this?
When using Postgraphile as a library and passing simpleCollections: 'only'
, the argument includeArchived
is not generated in schema and also there is no is_archived
column anywhere in the generated sql.
First of all, thank you for this great Postgraphile plugin ❤️ I appreciate all the effort you are putting into maintaining and improving this package.
In my project, I would like to use the recently added "advanced expressions" mode, which is available in v3.0.0 relase candidates only. (I am interested in TypeScript typings too, but those can be easily supplied by a .d.ts
file.)
The Releases
page shows that the last 3.0 release candidate was published back in August 2021.
What is your plan for 3.0 GA? Are there any features or bugfixes missing? How can we (the community of users) help the project to reach 3.0 GA sooner?
We have text column status
and we would like to omit rows with certain value(s).
The idea is to allow to configure the plugin with kind of expression (eg status != 'deleted'
). As we already have discussed, the syntax could be like:
pgStatusDeletedAppliesTo: ['app_public.my_table', 'app_public.my_other_table'],
pgStatusDeletedExpression: (sql, tableAlias) => sql.fragment`${tableAlias}.status != 'deleted'`,
I am looking into this plugin because recently a new requirement was added to my application: being able to see deleted entities, i.e.: soft deletes. This plugin looks perfect for my needs but I have a question regarding its usage along with user permissions.
I am currently using roles and row-level security to ensure users don't delete rows they shouldn't, but I am struggling to achieve the same result using this plugin. I understand that now instead of using delete*
mutations I have to use update*
mutations setting the archived
or deleted_at
fields to some value but this is not ideal for the tables where users should be able to update rows but not delete them.
A concrete example: in my application users can update their user profiles but they should not be able to delete them. What is even worse, since they can update the archived
field they can also set it to null
, essentially un-deleting their users.
Do you have suggestions about how to proceed in this case? Are there any other alternatives?
Thank you
@graphile-contrib/pg-omit-archived/dist/index.js:75
const pgRelevantColumnIsBoolean = relevantColumn?.type.category === "B";
^
SyntaxError: Unexpected token '.'
When importing the plugin as a module and including it in the array for appendPlugins, I receive the following error:
Option 'appendPlugins' should be an array of functions, found 'object' at index 0","stack":"Error: Option 'appendPlugins' should be an array of functions, found 'object' at index 0\n at ensureValidPlugins (/usr/src/app/node_modules/postgraphile-core/node8plus/index.js:18:19)\n at getPostGraphileBuilder (/usr/src/app/node_modules/postgraphile-core/node8plus/index.js:169:5)\n at createPostGraphileSchema (/usr/src/app/node_modules/postgraphile-core/node8plus/index.js:224:62)\n
I am importing as follows:
import PgOmitArchived from '@graphile-contrib/pg-omit-archived'
Using version ^3.2.1
Works fine when its just required instead of imported as module.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.