Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
type-graphql-utils
Advanced tools
This module provides utilities to transform type-graphql types.
yarn install type-graphql-utils
import { Field, InputType, ObjectType } from 'type-graphql';
import { Pick, Partial } from 'type-graphql-utils';
@ObjectType()
class User {
@Field()
id!: number;
@Field()
name!: string;
@Field()
email!: string;
}
type User {
id: String!
name: String!
email: String!
}
@InputType()
class UserInput1 extends Partial(User) {
// extra fields
}
input UserInput1 {
id: String
name: String
email: String
}
@InputType()
class UserInput2 extends Pick(User, { name: 1 }) { }
input UserInput2 {
name: String!
}
@InputType()
class UserInput3 extends Required(Partial(User), { id: 1 }) {}
input UserInput3 {
id: String!
name: String
email: String
}
BaseClass
: The type to transform. A class decorated with @InputType()
or @ObjectType()
.
names
: The fields to transform. A potentially optional object containing the names of the fields as key, e.g. { id: 1, name: 1 }
. The TypeScript type enforces all values to be 1, but the value isn't actually used. We just need the names as object to determine if a name is included in constant time.
Pick(BaseClass, names)
Constructs a type by picking the keys of names
from BaseClass
.
Omit(BaseClass, names)
Constructs a type by picking all fields from BaseClass
and then removing the keys of names
.
Partial(BaseClass, [names])
Constructs a type by picking all fields from BaseClass
and then setting the keys of names
to optional. The opposite of Required. By default, names
contains all names.
Required(BaseClass, [names])
Constructs a type by picking all fields from BaseClass
and then setting the keys of names
to required. The opposite of Partial. By default, names
contains all names.
FAQs
utilities to transform type-graphql types
We found that type-graphql-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.