nautilus / gateway

A federated api gateway for graphql services. https://gateway.nautilus.dev/
MIT License
397 stars 49 forks source link

Question: Does Nautilus gateway support the default directives #199

Closed angminsheng closed 4 months ago

angminsheng commented 11 months ago

Hello, I have been trying to add default directives in my gql query and came across this issue:

Given the example gql below:

This does not work. The parameter $returnUser seems to be undefined hence does not return the user info.

mutation login($login: String!, $password: String!, $returnUser: Boolean!) {
    login(login: $login, password: $password) {
        token
        user @include(if:$returnUser){
            firstName
            lastName
        }
    }
}

This works:

mutation login($login: String!, $password: String!, $deviceId: String!) {
    login(login: $login, password: $password, deviceId: $deviceId) {
        token
        user @include(if:true){
            firstName
            lastName
        }
    }
}

Am I doing something wrong here? Or is this some kind of limitation that we have in the library?

JohnStarich commented 4 months ago

@angminsheng Thank you for opening. This definitely should work but doesn't. I can reproduce too. I'll try and get a PR to fix up soon.

It looks like the current query planner only considered field arguments when collecting relevant variables, but not directive arguments..

JohnStarich commented 4 months ago

@angminsheng I know it's been a while but if you have time, please shout if the latest release did not address your issue.