
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
add-typenames
Advanced tools
addTypenames
copies a given input object and recursively adds GraphQL __typenames
to the output.
yarn install add-typenames graphql
const typedItem = addTypenames({ item, schema });
import addTypenames from 'add-typenames';
import { buildSchema } from 'graphql'
const typeDefs = `
""" Add your schema definition here
`;
const item = {
/* Your item to be typed */
};
const schema = buildSchema(typeDefs);
const typedItem = addTypenames({ item, schema });
Hint: Adding
__typename
to the root of the input item will resolve most issues that may arise by leveraging the schema to resolve all types rather than relying on heuristics
In order to properly resolve Unions, Interfaces and Scalars we need the resolvers for those types to be included as part of the schema.
This can be done with makeExecutableSchema
import { makeExecutableSchema } from '@graphql-tools/schema';
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
Hint: Only include the resolvers for Unions, Interfaces and Scalars. The rest are unused and not needed.
FAQs
Recursively adds __typename to the input using a passed in schema
The npm package add-typenames receives a total of 598 weekly downloads. As such, add-typenames popularity was classified as not popular.
We found that add-typenames 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.