nautilus / gateway

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

Fallback for the query operationName value #203

Open slavik-pastushenko opened 10 months ago

slavik-pastushenko commented 10 months ago

Hello! I am trying to migrate to this gateway and realised that I am not able to execute a query without specifying the operationName, meaning this query throws an exception:

query {
  random(id: "id") {
    id
    name
}

Looks like this is the place where we validate the operationName field: https://github.com/nautilus/gateway/blob/master/gateway.go#L69

Is it possible to set the fallback value instead of throwing an exception? As an example: solution

JohnStarich commented 4 months ago

@slavik-pastushenko I agree, operationName should definitely be optional. What's weird is I'm not able to reproduce on the latest version :thinking: Do you have additional queries in your request?

I used the gateway example "hello" here with operationName set to null (not provided) and "" successfully: image

From the code you've linked, I think that should only be hit if you have more than one operation in your query. In other words, gateway only requires the operation name when it's ambiguous which operation it should run.

I know it's been a few months since you opened this, but is this still happening for you? If you have an example with steps to reproduce, I can help dig into this further with you.