![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
graphql-codegen-fragment-masking
Advanced tools
Type-safe fragment masking plugin for GraphQL Code Generator, providing helper functions for managing GraphQL fragments with enhanced type safety and customizable configurations.
graphql-codegen-fragment-masking
is a custom plugin for GraphQL Code Generator that generates fragment masking helper functions for TypeScript. It enhances type safety by providing utility functions to manage GraphQL fragments, ensuring robust and maintainable client-side code.
Install via npm:
npm install -D graphql-codegen-fragment-masking
Install via yarn:
yarn add -D graphql-codegen-fragment-masking
Configure graphql-codegen-fragment-masking
in your codegen.ts
file to generate fragment masking helpers alongside your TypeScript types.
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
pluginLoader: (name) => import(name),
schema: "./src/schema.graphql",
documents: "./src/**/*.graphql",
generates: {
"./src/generated/fragment-masking.ts": {
plugins: ["fragment-masking"],
config: {
importIncrementalFrom: "./common-types",
unmaskFunctionName: "getFragmentData",
useTypeImports: true,
},
},
"./src/generated/common-types.ts": {
plugins: ["typescript"],
config: {
avoidOptionals: true,
},
},
},
};
export default config;
The plugin will generate helper functions such as FragmentType
, makeFragmentData
, and getFragmentData
based on your configuration. These helpers facilitate type-safe fragment management in your TypeScript code.
Given a GraphQL fragment:
fragment UserFragment on User {
id
name
}
And a corresponding TypeScript type:
import { FragmentType, getFragmentData } from "./generated/fragment-masking";
import { UserFragment } from "./generated/graphql";
const userData: FragmentType<typeof UserFragment> = {
id: "1",
name: "John Doe",
};
const user = getFragmentData(UserFragment, userData);
This setup ensures that user
is correctly typed, enhancing type safety and reducing potential runtime errors.
string
): Specifies the module to import incremental types from. Default is "./graphql"
.Unable to load template plugin matching 'fragment-masking'.
Reason:
require() of ES Module graphql-codegen-fragment-masking/out/index.js is not supported.
Instead change the require of index.js in ...
Solution:
This error occurs because @graphql-codegen
expects the plugin to be loaded in a specific way. To resolve this, ensure you have a pluginLoader
function in your GraphQL Code Generator configuration:
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
// ... other configurations
pluginLoader: (name) => import(name),
// ... other configurations
};
export default config;
This ensures the plugin is loaded as an ES module, preventing the require()
error.
All notable changes to this project will be documented in the CHANGELOG file.
This project is licensed under the MIT License. See the LICENSE file for details.
Note: Ensure that your project setup aligns with the plugin's requirements, especially regarding TypeScript configurations and GraphQL Code Generator versions.
FAQs
Type-safe fragment masking plugin for GraphQL Code Generator, providing helper functions for managing GraphQL fragments with enhanced type safety and customizable configurations.
The npm package graphql-codegen-fragment-masking receives a total of 70 weekly downloads. As such, graphql-codegen-fragment-masking popularity was classified as not popular.
We found that graphql-codegen-fragment-masking demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.