Hello, I have a question regarding eg's `graphql-...
# graphql-kotlin
z
Hello, I have a question regarding eg's
graphql-kotlin-spring-server
. We are using the library for one of our service and we want to differentiate the
playground
calls vs regular api calls to our endpoint
/graphql
Is there a way to do this? Or is there a way to add some configuration to add a custom header for
playground
requests to help us differentiate these calls? The context is that some clients are calling our
/graphql
endpoint and we would like to block direct calls to that endpoint but not block the playground which calls the same endpoint. Any help is appreciated, Thank you
d
Hello 👋 While it is not out-of-box solution, you should be able to do it -> you would need to 1. copy
graphql-playground.html
to your project 2. update settings to specify global header here -> (https://github.com/ExpediaGroup/graphql-kotlin/blob/master/servers/graphql-kotlin-spring-server/src/main/resources/graphql-playground.html#L53), see https://github.com/graphql/graphql-playground#properties 3. Disable default playground round and create your own instead (see https://github.com/ExpediaGroup/graphql-kotlin/blob/master/servers/graphql-kotlin-[…]ediagroup/graphql/server/spring/PlaygroundRouteConfiguration.kt) 4. Add some WebFilter to your server to inspect incoming requests and look for expected header
z
Sounds good, thanks for the reply! I will try that out 🙂
Hey @Dariusz Kuc 👋 Thanks again for providing the work around solution. I followed your suggestion and I managed to setup everything. But the
globalHeaders
is not being reflected in the
playground
. In my
graphql-playground.html
I set the
globalHeaders
to some value (see screenshot) but incoming requests are not showing that header. I noticed that in playground settings the globalHeaders are not showing up like the ones defined in the
html
. But if I change the globalHeaders in playground settings, I will see the header in my WebFilter. Do you know what the issue might be?
d
Might be playground issue -> you can try raising issue there... but the project is deprecated in favor of graphiql so dont think it is going to be fixed You can try using graphiql instead and see if it works