Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const plugin: PluginFunction = (
schema: GraphQLSchema,
documents: Types.DocumentFile[],
// eslint-disable-next-line @typescript-eslint/no-unused-vars
config: RelayOptimizerPluginConfig
) => {
// @TODO way for users to define directives they use, otherwise relay will throw an unknown directive error
// Maybe we can scan the queries and add them dynamically without users having to do some extra stuff
// transformASTSchema creates a new schema instance instead of mutating the old one
const adjustedSchema = RelayCreate.create(
printSchemaWithDirectives(
transformASTSchema(schema, [
/* GraphQL */ `
directive @connection(key: String!) on FIELD
directive @client on FIELD
`,
])
)
);
const documentAsts = documents.reduce((prev, v) => {
return [...prev, ...v.content.definitions];
}, [] as DefinitionNode[]);
const relayDocuments = RelayParser.transform(adjustedSchema, documentAsts);
const fragmentCompilerContext = new GraphQLCompilerContext(adjustedSchema).addAll(relayDocuments);
const fragmentDocuments = fragmentCompilerContext
export const plugin: PluginFunction = (
schema: GraphQLSchema,
documents: Types.DocumentFile[],
// eslint-disable-next-line @typescript-eslint/no-unused-vars
config: RelayOptimizerPluginConfig
) => {
// @TODO way for users to define directives they use, otherwise relay will throw an unknown directive error
// Maybe we can scan the queries and add them dynamically without users having to do some extra stuff
// transformASTSchema creates a new schema instance instead of mutating the old one
const adjustedSchema = transformASTSchema(schema, [
/* GraphQL */ `
directive @connection(key: String!) on FIELD
directive @client on FIELD
`
]);
const documentAsts = documents.reduce(
(prev, v) => {
return [...prev, ...v.content.definitions];
},
[] as DefinitionNode[]
);
const relayDocuments = RelayParser.transform(adjustedSchema, documentAsts);
const fragmentCompilerContext = new GraphQLCompilerContext(
adjustedSchema