Giter Site home page Giter Site logo

graphql-joi-directives's People

Contributors

ephys avatar

Stargazers

 avatar  avatar

Watchers

 avatar

graphql-joi-directives's Issues

Using in Query variables result in GraphQL validation error

First of all, great work building this. I have seen other libraries which are not maintained and doesn't work for ARGUMENT_DEFINITIONs. I've noticed a problem while using this with query variables. Example:

I have a query which looks like the following:

query searchResults($nameLike: String, $limit: Int) {
  person(nameLike: $nameLike, limit: $limit) {
    id
    name 
  }

and variable:

{
  "nameLike": "Dina",
  "limit": 100
}

Schema is decorated with @int(min:1)

Error:

{
  "errors": [
    {
      "message": "Variable \"$limit\" of type \"Int\" used in position expecting type \"ConstrainedInt__min_1\".",
      "locations": [
        {
          "line": 1,
          "column": 40
        },
        {
          "line": 2,
          "column": 50
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED",
        "exception": {
          "stacktrace": [
            "GraphQLError: Variable \"$limit\" of type \"Int\" used in position expecting type \"ConstrainedInt__min_1\".",
            "    at Object.leave (/Users/dina/example/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js:55:35)",
            "    at Object.leave (/Users/dina/example/node_modules/graphql/language/visitor.js:344:29)",
            "    at Object.leave (/Users/dina/example/node_modules/graphql/utilities/TypeInfo.js:390:21)",
            "    at visit (/Users/dina/example/node_modules/graphql/language/visitor.js:243:26)",
            "    at Object.validate (/Users/dina/example/node_modules/graphql/validation/validate.js:69:24)",
            "    at /Users/dina/example/node_modules/@opentelemetry/instrumentation-graphql/build/src/instrumentation.js:197:33",
            "    at Object.safeExecuteInTheMiddle (/Users/dina/example/node_modules/@opentelemetry/instrumentation/build/src/utils.js:28:18)",
            "    at /Users/dina/example/node_modules/@opentelemetry/instrumentation-graphql/build/src/instrumentation.js:196:38",
            "    at async_hooks.js:312:14",

The problem seems to be happening as we are declaring the limit variable as Int where as it was changed by the directive to ConstrainedInt__min_1. Do you know how to go about this? Changing the type of query variable to ConstrainedInt__min_1 is not a viable solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.