Will this work with the new @neo4j/graphql library?
tirth0 opened this issue ยท 2 comments
I'm trying to use this with Neo4jGraphQL constructor instead of makeAugmentedSchema but I'm getting the following error :
TypeError: schema.getTypeMap is not a function
at mapSchema (/home/tirtho/Desktop/mslate-graph/graphql/node_modules/graphql-rate-limit-directive/node_modules/@graphql-tools/utils/index.js:2382:120)
at rateLimitDirectiveTransformer (/home/tirtho/Desktop/mslate-graph/graphql/node_modules/graphql-rate-limit-directive/src/index.ts:247:16)
at Object. (/home/tirtho/Desktop/mslate-graph/graphql/index.js:87:19)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Module._compile (/home/tirtho/Desktop/mslate-graph/graphql/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
at Object.newLoader [as .js] (/home/tirtho/Desktop/mslate-graph/graphql/node_modules/pirates/lib/index.js:104:7)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:816:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
๐ You can provide some example code reproducing your problem.
Having not used Neo4jGraphQL
, I haven't tried it with that library, but I suspect it should work (or at least isn't the shortcomings of this library). Based on their getting started guide, I would assume you could have something like:
const { Neo4jGraphQL } = require("@neo4j/graphql");
const { ApolloServer, gql } = require("apollo-server");
const { rateLimitDirective } = require('graphql-rate-limit-directive');
const neo4j = require("neo4j-driver");
const { rateLimitDirectiveTypeDefs, rateLimitDirectiveTransformer } = rateLimitDirective();
// ... your / neo4j code ...
const neoSchema = new Neo4jGraphQL({
typeDefs: [
rateLimitDirectiveTypeDefs,
/* add your type definitions here too */
],
driver
});
const schema = rateLimitDirectiveTransformer(neoSchema.schema);
const server = new ApolloServer({ schema });
server.listen().then(({ url }) => {
console.log(`๐ Server ready at ${url}`);
});
[Neo4jGraphQL constructor input] accepts all of the options from
makeExecutableSchema
, plus the additional arguments below:
This works! Thank you so much.