Comments (35)
The graphiql page loads but the post when submitting a query doesn't work. Another idea is to use an InMemoryFileProvider for the JavaScript currently in the html page, which we can modify with the correct path. Will try to get a version of this going.
from graphiql-dotnet.
Hi @srini85,
Thanks for raising this, I'll have to take a look to confirm then get back to you.
from graphiql-dotnet.
Hello. Could we please get this issue addressed? We are facing the same issue, as Graphql is part of a versioned solution (so it runs as my.service.com/1.0/graphql). Actually simply removing the path from here https://github.com/JosephWoodward/graphiql-dotnet/blob/master/src/graphiql/assets/index.html#L112 should do the trick as it then makes a request to the resource itself. That should satisfy all cases, regardless if you are hosting under a completely custom URL or "just" in a subdirectory like we are.
from graphiql-dotnet.
Actually, digging deeper, the real problem is that GraphiQL treats the server and JS paths the same. If you have a setup in IIS like this ...
Then IIS strips the "1.0" out of the path. So from JS side your URL is /1.0/graphql
while from C# side (i.e. in GraphiQlConfig
or the FileServerOptions
built here) the path should just be /graphql
.
from graphiql-dotnet.
Is there any chance you'd be able to create a repo of this issue as I'm struggling to reproduce it?
Alternatively, what does your configuration look like? I see you're running it from localhost in your screenshots? Earlier you mentioned it was only when you published your app to IIS? (or does it also do it if you're running it via IIS locally?)
from graphiql-dotnet.
@srini85 it seems ok when running the example project. what was your plan with this? i'm not sure how best to templatize the html, since it's just an embedded file
from graphiql-dotnet.
@simonpetty want to use an alternative location to /graphql. I was thinking of doing it at build time by setting it in the configuration json and then using that as part of the build process. However I couldn't get the project working when I built it myself. So hence wondering if the nuget version is different to the the master src.
from graphiql-dotnet.
Another option would be to use the .NET Core proxy library to capture requests to a custom endpoint and proxy them to /graphql.
@srini85 Were you working from a fresh clone of master? I've just did a hard reset (git reset --hard origin/master
) to master, then a dotnet restore
then ran (using dotnet run
) the samples project then navigated to http://localhost:5000/graphql/ and can confirm it works.
How are you launching it?
from graphiql-dotnet.
@srini85 I've just tried launching Graphiql from a custom location (/hello
instead of the default /graphql
) and can confirm that it does work. Can you provide a repository of what you're trying to do so I can take a look?
from graphiql-dotnet.
@josephwoodward I will see if I get time to push that repository I was working with. Maybe I am missing something, but deffinately did work of a fresh clone of master with no changes. But if you are confirming that it deffinately does work, perhaps I am missing some step or my environment is not quite right. I will continue to dig and let you know the result.
Just out of curiousity, when you said it worked, are you referring to graphiql loading or loading and making requests to the server? Seeing that the fetch promise is set to /graphql
, wondering how that gets updated if your controller location is set to something like /hello
(as per the original issue comment)?
from graphiql-dotnet.
@srini85 It's done here, allowing you to serve files from a specific location.
from graphiql-dotnet.
@simonpetty Weird, I'm sure I tried posting a query, I'll take another look and check it out. I think there are a few options we could use to get that working, such as the proxy which I mentioned above.
from graphiql-dotnet.
Another option would be to use the .NET Core proxy library to capture requests to a custom endpoint and proxy them to /graphql.
This does not work when hosting under IIS virtual directory. For me a path relative to graphiql would solve the issue...
from graphiql-dotnet.
I also am trying to change the routes to /foo/graphiql
and /bar/graphql
. The problem is client side requests are always made for /graphql
path.
from graphiql-dotnet.
Yeah, this seems to be the biggest blocker. I'm considering adding a template string to the index.html
then doing a replace on it, something like:
return fetch('{{ graphqlPath }}', {
Seems like the easiest option.
from graphiql-dotnet.
@josephwoodward That should work. Do you think we would have a release anytime soon?
from graphiql-dotnet.
@pouladpld Hopefully either this week or next by the latest.
from graphiql-dotnet.
Can't wait 😄 I'll try making a PR.
from graphiql-dotnet.
Have an open PR for this (#23) which I'm currently testing an will release in the next few days.
from graphiql-dotnet.
This has now been released as a beta package, if you would mind giving it a try and reporting back if you find any issues. You can find the beta here.
I'd like to give a special thanks for @pouladpld for his pull request to get the ball rolling on this.
from graphiql-dotnet.
Hi!
We are currently testing this. While this change allows us to explicitly set our path (eg. "/1.0/GraphQl"
), I would argue this change would work better if this variable is an empty string (so that calls on the interface go to the same URL the interface is hosted on) or at least this check should be removed so we can manually do app.UseGraphiQl("");
if we want this behaviour.
Cheers
from graphiql-dotnet.
Thanks for giving the beta try!
So from JS side your URL is /1.0/graphql while from C# side (i.e. in GraphiQlConfig or the FileServerOptions built here) the path should just be /graphql
I don't have IIS to hand as I use a Mac/Linux, any thoughts how we could resolve this? Not sure how we could get around IIS stripping values from the path, feels like that shouldn't be the responsibility of this library. Thoughts?
from graphiql-dotnet.
Yes, I am absolutely with you, it's not your responsibility to know that. Obvious "worst case" solution is allowing setting of JS and C# paths separately, but that really isn't elegant.
from graphiql-dotnet.
@FrankyBoy Though I'm wondering if there would be any use cases for adding an overload to enable you to configure the JS and C# paths separately. I'm not completely against the idea.
from graphiql-dotnet.
Other than my use case (i.e. IIS being weird) I see also this one: Having a separate configuration would make sense if someone wants to host the UI in a different location than the actual graphql endpoint. Like /docs
for the interface and /graphql
for the actual graphql endpoint. That would require different paths for the FileServerOptions and the path in the delivered JS as well. You could even target another server entirely (for instance to host a sort of centralized documentation site where you can switch between different services quickly).
Not sure if anyone would ever want to do that, it's just another potential use case I see.
from graphiql-dotnet.
Any update here? Should I just push a change that lets us configure server and client path independently or can you look into the topic?
Cheers!
from graphiql-dotnet.
1.2.0 has now been published to NuGet, I will now close this PR. If anyone has any issues then please feel free to reopen it.
from graphiql-dotnet.
In my solution works normally but when publish in IIS server show this empty string ""
from graphiql-dotnet.
In my Solution is fine, Which may be?
from graphiql-dotnet.
@areyes21 That's odd. If you perform the query via a raw HTTP Request (as opposed to using GraphiQL), do you get any results? That would isolate the issue to this library.
Also, have you looked in your browser's dev tools? GraphiQL queries your API via an ajax request so it would seem that your API is returning no data?
Is the schema viewer working?
from graphiql-dotnet.
The route of graphqlpath is /GraphQL But if I change graphqlpath for an empty string it works well.
from graphiql-dotnet.
Sorry I do not speak English but I will do my best to explain
from graphiql-dotnet.
I could solve it, adding what I show in the screenshots (EN)
Lo pude resolver, agregando lo que le muestro en las capturas de pantalla (ES)
from graphiql-dotnet.
Thanks for all the help, Greetings from Nicaragua
from graphiql-dotnet.
I'm glad you got this sorted in the end, I'm going to mark this issue as closed.
from graphiql-dotnet.
Related Issues (20)
- Cannot get Mutation work HOT 1
- Separate routs for GraphQL and GraphiQL HOT 3
- Docs sidebar not working HOT 4
- Cannot find schema HOT 4
- OAuth integration? HOT 2
- graphql/ not loading, js error. Can't get schema. HOT 2
- Don't require path in UseGraphiQl to be absolute HOT 4
- Missing schema intellisense HOT 4
- Need to import GraphiQl namespace since GraphiQL 1.2.0 HOT 1
- Undefined Type on autocompletion
- Investigate how we could handle authentication of the graphiql endpoint HOT 4
- Drop Down Menu Selection Not Executing Correct Operation HOT 2
- How to use with .net 4.7 HOT 2
- Autosuggestion and document explorer not working with .Net core 3.1.1 HOT 3
- Get tests running in GitHub actions HOT 2
- Support graphiql-explorer plugin HOT 1
- Custom js support HOT 3
- Console error within graphiql-ui (404 POST ERROR)
- to delete HOT 1
- Error 500 while fetching document after version Upgrade of both graphiql and graphql.net
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphiql-dotnet.