-
Notifications
You must be signed in to change notification settings - Fork 165
fix: url issue for path string for ui tools (playground, voyager, graphiql) #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
113cd60
97ef828
d434e7d
fef8cde
2d0c724
947ea69
baaf028
0113ca9
a78cdca
b43e7fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| <!-- | ||
| <!-- | ||
| * Copyright (c) Facebook, Inc. | ||
| * All rights reserved. | ||
| * | ||
|
|
@@ -96,25 +96,34 @@ | |
| function onEditOperationName(newOperationName) { | ||
| parameters.operationName = newOperationName; | ||
| updateURL(); | ||
| } | ||
| } | ||
|
|
||
| function updateURL() { | ||
| var newSearch = '?' + Object.keys(parameters).filter(function (key) { | ||
| return Boolean(parameters[key]); | ||
| }).map(function (key) { | ||
| return encodeURIComponent(key) + '=' + | ||
| encodeURIComponent(parameters[key]); | ||
| }).join('&'); | ||
| history.replaceState(null, null, newSearch); | ||
| } | ||
| function updateURL() { | ||
| var newSearch = '?' + Object.keys(parameters).filter(function (key) { | ||
| return Boolean(parameters[key]); | ||
| }).map(function (key) { | ||
| return encodeURIComponent(key) + '=' + | ||
| encodeURIComponent(parameters[key]); | ||
| }).join('&'); | ||
| history.replaceState(null, null, newSearch); | ||
| } | ||
|
|
||
| function stripGraphQLUiEndPointFromPathName(graphQlUiEndpoint) { | ||
| var currentPathName = window.location.pathname; | ||
| var regex = new RegExp(graphQlUiEndpoint + "\/*"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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... |
||
| currentPathName = currentPathName.replace(regex, ''); | ||
| return currentPathName; | ||
| } | ||
|
|
||
| var strippedCurrentPathName = stripGraphQLUiEndPointFromPathName("@Model.GraphiQLPath"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This injected variable appears to be encoded for HTML instead of for Javascript - correct? Or does Razor detect that it's within a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Razor? No Razor here 🤔 .
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cshtml are razor pages and
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes but ... no Razor engine/stuff/handlers/compilers here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just good old
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I see. Then we should modify the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| // Defines a GraphQL fetcher using the fetch API. You're not required to | ||
| // use fetch, and could instead implement graphQLFetcher however you like, | ||
| // as long as it returns a Promise or Observable. | ||
| function graphQLFetcher(graphQLParams) { | ||
| function graphQLFetcher(graphQLParams) { | ||
| // This example expects a GraphQL server at the path /graphql. | ||
| // Change this to point wherever you host your GraphQL server. | ||
| return fetch(window.location.protocol + "//" + window.location.host + '@Model.GraphQLEndPoint', { | ||
| return fetch(window.location.protocol + "//" + window.location.host + strippedCurrentPathName + '@Model.GraphQLEndPoint', { | ||
|
Shane32 marked this conversation as resolved.
|
||
| method: 'post', | ||
| headers: { | ||
| 'Accept': 'application/json', | ||
|
|
@@ -134,7 +143,7 @@ | |
| } | ||
|
|
||
| // Enable Subscriptions via WebSocket | ||
| var subscriptionsClient = new window.SubscriptionsTransportWs.SubscriptionClient((window.location.protocol === "http:" ? "ws://" : "wss://") + window.location.host + "@Model.GraphQLEndPoint", { reconnect: true }); | ||
| var subscriptionsClient = new window.SubscriptionsTransportWs.SubscriptionClient((window.location.protocol === "http:" ? "ws://" : "wss://") + window.location.host + strippedCurrentPathName, { reconnect: true }); | ||
| var subscriptionsFetcher = window.GraphiQLSubscriptionsFetcher.graphQLFetcher(subscriptionsClient, graphQLFetcher); | ||
|
|
||
| // Render <GraphiQL /> into the body. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.