
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@threads/apollo-resolver-types
Advanced tools
Strong typing for apollo resolvers
To setup a graphql server with strong types you will need the following:
ApolloResolverTypes to mark any necessary resolvers as required.Since the type definitions for GraphQL can get pretty big, you might find TypeScript runs out of memory. This can usually be solved by replacing your
tsccall withNODE_OPTIONS=\"--max-old-space-size=2048\" tsc.
./src/graphql/ResolverTypes.ts should look like:
import ApolloResolverTypes from '@threads/apollo-resolver-types';
import * as GeneratedTypes from './__generated__/types';
type ResolverTypes = ApolloResolverTypes<GeneratedTypes.Resolvers>;
export default ResolverTypes;
You can then refer to ResolverTypes['Query']['contactById'] to get the type of the contactById resolver or ResolverTypes['Contact']['accounts'] to get the accounts resolver on the Contact object.
To generate the types from your schema, run: apollo-resolver-types src/graphql/codegen.yml. If you've configured it as per the example, this will output two files in the src/graphql/__generated__ directory. For a full list of available config options, see https://graphql-code-generator.com/
apollo-resolver-types codegen-config.yml [options]
Options:
-w, --watch Watch for changes and execute generation automatically
Sometimes you might be unclear on why a given resolver is required. You might think it should be optional, but apollo-resolver-types says it's required. To resolve this you can try:
import * as GeneratedTypes from './__generated__/types';
import {DebugResolver} from '@threads/apollo-resolver-types';
type X = DebugResolver<GeneratedTypes.Resolvers['Contact'], 'accounts'>;
You can then hover over X and you should see something like:
type X = {
requiredValue: Account[];
implicitValue: undefined;
};
The requiredValue is the type defined in the GraphQL schema. The implicitValue is the value in TypeScript. If the implicitValue is assignable to the requiredValue, no resolver should be required. In the above example, undefined cannot be assigned to Account[], so you will need a resolver for Contact.accounts.
FAQs
Strong typing for apollo resolvers
We found that @threads/apollo-resolver-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.