Security News
RubyGems.org Adds New Maintainer Role
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.
graphql-codegen-factories
Advanced tools
graphql-codegen-factories
is a plugin for GraphQL Code Generator that generates factories from a GraphQL schema and operations.
The factories can then be used to mock data, e.g for testing or seeding a database.
For example, given this GraphQL schema:
type User {
id: ID!
username: String!
}
The following factory will be generated:
export type User = /* generated by @graphql-codegen/typescript */;
export function createUserMock(props: Partial<User> = {}): User {
return {
__typename: "User",
id: "",
username: "",
...props,
};
}
It is also possible to generate factories from an operation, for example:
query GetUser {
user {
id
username
}
}
Will result in the following factories:
export type GetUserQuery = /* generated by @graphql-codegen/typescript-operations */;
export function createGetUserQueryMock(props: Partial<GetUserQuery> = {}): GetUserQuery {
return {
__typename: "Query",
user: createGetUserQueryMock_user({}),
...props,
};
}
export function createGetUserQueryMock_user(props: Partial<GetUserQuery["user"]> = {}): GetUserQuery["user"] {
return {
__typename: "User",
id: "",
username: "",
...props,
};
}
You can also use a fake data generator to generate realistic factories such as:
import { faker } from "@faker-js/faker";
export function createUserMock(props: Partial<User> = {}): User {
return {
__typename: "User",
id: faker.random.alphaNumeric(16),
username: faker.lorem.word(),
...props,
};
}
Are you using this plugin? Let us know!
1.2.1 - 2023-03-06
FAQs
graphql-codegen plugin to generate factories
We found that graphql-codegen-factories 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
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.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.