leangen / graphql-spqr

Build a GraphQL service in seconds
Apache License 2.0
1.09k stars 181 forks source link

Replace the default Nashorn-based ComplexityFunction #452

Closed kaqqao closed 1 year ago

kaqqao commented 1 year ago

Nashorn was removed from JDK15+. The Spring project will get a SpEL-based implementation, but core SPQR needs an alternative that's not dependent on Spring. A simple implementation of Dijkstra's shunting yard algo will suffice.

kaqqao commented 1 year ago

The JavaScript (Nashorn) based evaluator is still available (and supported as usual), but must be configured explicitly:

GraphQL exe = GraphQLRuntime.newGraphQL(schema)
                .maximumQueryComplexity(maxComplexity, new JavaScriptEvaluator())
                .build();

If Nashorn engine isn't available (JDK15+), the dependency must be added by the user.