Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@graphile-contrib/constraint-error-tags
Advanced tools
A PostGraphile plugin for writing nicer error messages on constraints.
A PostGraphile plugin for writing nicer error messages on constraints. Adding the @error <message>
smart tag to constraints will replace generic Postgres constraint violation message.
npm install --save @graphile-contrib/constraint-error-tags
or
yarn add @graphile-contrib/constraint-error-tags
Library:
const {
ConstraintErrorTagsPlugin,
handleErrors,
} = require("@graphile-contrib/constraint-error-tags");
app.use(
postgraphile(process.env.POSTGRES_ENDPOINT, process.env.POSTGRES_SCHEMA, {
appendPlugins: [ConstraintErrorTagsPlugin],
handleErrors: (errors) => handleErrors(errors),
})
);
ConstraintErrorTagsPlugin
introspects all your constraints and extracts the ones with the @error <message>
smart tag.handleErrors
violating a constraint with the above mentioned signature will replace the generic error with the <message>
from the @error
smart tag.SQL schema:
create table public.user (
id serial primary key,
first_name text not null,
last_name text not null,
age int not null,
constraint age_check check(age >= 18)
);
comment on constraint "age_check" on "public.user" is '@error The user has to be at least 18 years of age.';
GraphQL mutation:
mutation {
createUser(input: { firstName: "John", lastName: "Doe", age: 16 }) {
clientMutationId
}
}
Response:
GraphQL error with the message: The user has to be at least 18 years of age.
SQL schema:
create domain strong_password as text
constraint "symbol" check (value ~ '[!@#$%^&*()]');
comment on constraint "symbol" on domain "strong_password" is '@error password must contain at least one symbol of !@#$%^&*()';
GraphQL mutation:
mutation {
setPassword(input: {userId: "100", newPass: "weakpassword"}) {
clientMutationId
}
}
Response:
GraphQL error with the message: password must contain at least one symbol of !@#$%^&*()
FAQs
A PostGraphile plugin for writing nicer error messages on constraints.
The npm package @graphile-contrib/constraint-error-tags receives a total of 16 weekly downloads. As such, @graphile-contrib/constraint-error-tags popularity was classified as not popular.
We found that @graphile-contrib/constraint-error-tags demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.