fix: url issue for path string for ui tools (playground, voyager, graphiql)#195
Conversation
…hema_fetch' of https://github.com/pobisw/server into pobisw/Fix_playground_graphiql_path_string_issue_for_schema_fetch
|
@pekkah @BenjaBobs Can you please take a look at this PR |
|
@joemcbride @pekkah please review |
|
@pekkah can you please look at this ? this issue is blocking our development |
joemcbride
left a comment
There was a problem hiding this comment.
I mentioned this in the other issue, though this seems to make it so you can’t have your GraphQL endpoint at a different root url, which is a valid scenario. Is there something blocking you from setting that url to the path that you need?
I have replied in the other issue, restating it here, we have multiple int and dev root urls, so we cant set it to a fixed value |
|
@pobisw Thanks for this PR. I will try to review it if you resolve conflicts. Also, could you not change the indentation in the |
|
OK |
|
just saw the comments, will make the changes |
| return currentPathName; | ||
| } | ||
|
|
||
| var strippedCurrentPathName = stripGraphQLUiEndPointFromPathName("@Model.GraphiQLPath"); |
There was a problem hiding this comment.
This injected variable appears to be encoded for HTML instead of for Javascript - correct? Or does Razor detect that it's within a <script> tag and encode it differently?
There was a problem hiding this comment.
cshtml are razor pages and @Model.GraphiQLPath is razor injecting a variable. By default it will format variables with html encoding. So I always use JavaScript encoding as shown below when injecting a variable into a script tag like this. Or encode it as json and then inject it. Or put it into a html tag and read the tag.
There was a problem hiding this comment.
cshtml are razor pages
Yes but ... no Razor engine/stuff/handlers/compilers here.
There was a problem hiding this comment.
Ok I see. Then we should modify the string.Replace encode to javascript-encode the variables for use on the page. Probably not a critical fix as the url is controlled by the setup code, not user input.
|
|
||
| function stripGraphQLUiEndPointFromPathName(graphQlUiEndpoint) { | ||
| var currentPathName = window.location.pathname; | ||
| var regex = new RegExp(graphQlUiEndpoint + "\/*"); |
There was a problem hiding this comment.
Here the path name from the model variable is passed directly into a regular expression without encoding. Also seems wrong. Maybe this should not be using regexp at all and just perform a simple replace...
@pobisw Thanks for the fix. The main thing here is to resolve conflicts, after which we can continue review. |
|
Replaced by #853 |

fixes #184