graphql-crystal icon indicating copy to clipboard operation
graphql-crystal copied to clipboard

Response for graphiQL does not work correctly

Open Stanislav-Lapata opened this issue 7 years ago • 2 comments

I use https://github.com/skevy/graphiql-app request with params

query IntrospectionQuery {
  __schema {
    queryType {
      name
    }
    mutationType {
      name
    }
    subscriptionType {
      name
    }
    types {
      ...FullType
    }
    directives {
      name
      description
      locations
      args {
        ...InputValue
      }
    }
  }
}

fragment FullType on __Type {
  ...
}

fragment InputValue on __InputValue {
  ...
}

fragment TypeRef on __Type {
  ...
}

return

{"data":{"__schema":{...}, "errors":[{"message":"field not defined.","path":["__schema","subscriptionType"]}]}

Should be without the "errors" key or with the "errors" key but without the "__schema" key See please here and here Validate struct should be before execution code in app also method max_depth should ignore this request

Sorry for my English

Stanislav-Lapata avatar Jan 19 '18 11:01 Stanislav-Lapata

ok, it seems the graphql spec changed. I was used to the field that's having an error being returned as nil. Having the app check the query before execution would add to execution time but might be a good idea anyways.

I'm not sure if ignoring max_depth for the __schema request is a good idea as it opens up the system forattacks if the schema has circular associations like address having a user and user having an address. In this case a query with a fragment might lead to endless loops.

I will look into that as soon as I find the time. Feel free to add a pull request if you need this fast...

ziprandom avatar Jan 19 '18 13:01 ziprandom

Maybe then put a default value of 20-50?

Stanislav-Lapata avatar Jan 19 '18 19:01 Stanislav-Lapata