Typescript types dependencies in standalone mode
Hi!
I'm trying to use @escape.tech/graphql-armor-max-depth as a standalone module, so I added it together with @escape.tech/graphql-armor-types, and imported it like so import { maxDepthPlugin } from '@escape.tech/graphql-armor-max-depth'.
I get a bunch of errors coming from @escape.tech/graphql-armor-types/dist/declarations/src/index.d.ts when compiling (eg. error TS2307: Cannot find module '@escape.tech/graphql-armor-block-field-suggestions' or its corresponding type declarations.).
So I'm wondering, is this module supposed to be used with skipLibCheck: true in the tsconfig.json, should it actually work out of the box, or am I doing it wrong?
Thanks!
@Marsup Seems like module is not present in your installed dependencies. First thing to do is to make sure you install that dependency: npm install @escape.tech/graphql-armor-max-depth
Make sure you customize the limits when declaring/defining armor: const armor = new ApolloArmor({ costLimit: { enabled: Boolean(LimitENABLED), maxCost: Number(maxCount), objectCost: Number(objectCount), scalarCost: Number(scalarCount), depthCostFactor: Number(depthFactorCount), ignoreIntrospection: Boolean(ignoreIntrospectionENABLED), }, maxAliases: { enabled: Boolean(maxAliasesENABLED), n: Number(maxAliasesCount) }, maxDirectives: { n: Number(maxDirectivesCount) }, maxDepth: { n: Number(maxDepthCount) }, maxTokens: { n: Number(maxTokenCount) } });
Hey @Marsup,
I seemed to have overlooked one.
Could you please install the optional dependencies @escape.tech/graphql-armor-types?
Let me know if that resolves the issue!
@simpyparveen the module is present, the other aren't, rightfully so, since I'm not going to use them.
@c3b5aw it is already installed, it is the cause of the error, since it imports modules that aren't declared in its package.json and that I haven't installed since I have no use for them.
@simpyparveen the module is present, the other aren't, rightfully so, since I'm not going to use them.
@c3b5aw it is already installed, it is the cause of the error, since it imports modules that aren't declared in its package.json and that I haven't installed since I have no use for them.
Alright, any fix in mind ? Otherwise, I'll try to reproduce during the week.
It seems that all the plugins only ever need is GraphQLArmorCallbackConfiguration, how about splitting the definition in 2 files and importing only that part in the plugins?
I am using ApolloServer, plugins on Escape's docs are for Envelope. I missed that.
-
Setting skipLibCheck to true in your tsconfig.json file will resolve TypeScript type checking issues, but it's important to understand what this option does. This will make TypeScript skip type checking of declaration files (.d.ts files) that are included as part of all your dependencies.
-
If the module you are trying to use does not come with its own type declarations, TypeScript might not be able to infer the types. In this case, you might need to provide your own type declarations or use TypeScript's declare keyword to declare the module type. Declare the module by creating a file with a .d.ts extension in your project.
-
Try clearing the TypeScript cache by deleting the node_modules folder, the package-lock.json (or yarn.lock) file, and then reinstalling your dependencies.
Inactive thread, closing.