Code Monkey home page Code Monkey logo

Comments (35)

simonpetty avatar simonpetty commented on June 19, 2024 3

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.

josephwoodward avatar josephwoodward commented on June 19, 2024 1

Hi @srini85,

Thanks for raising this, I'll have to take a look to confirm then get back to you.

from graphiql-dotnet.

FrankyBoy avatar FrankyBoy commented on June 19, 2024 1

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.

FrankyBoy avatar FrankyBoy commented on June 19, 2024 1

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 ...
image
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.

josephwoodward avatar josephwoodward commented on June 19, 2024 1

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.

simonpetty avatar simonpetty commented on June 19, 2024

@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.

srini85 avatar srini85 commented on June 19, 2024

@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.

josephwoodward avatar josephwoodward commented on June 19, 2024

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.

josephwoodward avatar josephwoodward commented on June 19, 2024

@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.

srini85 avatar srini85 commented on June 19, 2024

@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.

josephwoodward avatar josephwoodward commented on June 19, 2024

@srini85 It's done here, allowing you to serve files from a specific location.

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

@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.

PeterHageus avatar PeterHageus commented on June 19, 2024

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.

poulad avatar poulad commented on June 19, 2024

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.

https://github.com/JosephWoodward/graphiql-dotnet/blob/979199d78ab4c393617416eb4e7cc3605032c5ec/src/graphiql/assets/index.html#L112

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

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.

poulad avatar poulad commented on June 19, 2024

@josephwoodward That should work. Do you think we would have a release anytime soon?

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

@pouladpld Hopefully either this week or next by the latest.

from graphiql-dotnet.

poulad avatar poulad commented on June 19, 2024

Can't wait 😄 I'll try making a PR.

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

Have an open PR for this (#23) which I'm currently testing an will release in the next few days.

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

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.

FrankyBoy avatar FrankyBoy commented on June 19, 2024

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.

josephwoodward avatar josephwoodward commented on June 19, 2024

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.

FrankyBoy avatar FrankyBoy commented on June 19, 2024

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.

josephwoodward avatar josephwoodward commented on June 19, 2024

@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.

FrankyBoy avatar FrankyBoy commented on June 19, 2024

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.

FrankyBoy avatar FrankyBoy commented on June 19, 2024

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.

josephwoodward avatar josephwoodward commented on June 19, 2024

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.

areyes21 avatar areyes21 commented on June 19, 2024

In my solution works normally but when publish in IIS server show this empty string ""
imagen

from graphiql-dotnet.

areyes21 avatar areyes21 commented on June 19, 2024

In my Solution is fine, Which may be?
imagen

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

@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.

areyes21 avatar areyes21 commented on June 19, 2024

The route of graphqlpath is /GraphQL But if I change graphqlpath for an empty string it works well.

Line of code
imagen

imagen

imagen

from graphiql-dotnet.

areyes21 avatar areyes21 commented on June 19, 2024

Sorry I do not speak English but I will do my best to explain

from graphiql-dotnet.

areyes21 avatar areyes21 commented on June 19, 2024

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)

imagen

imagen

imagen

from graphiql-dotnet.

areyes21 avatar areyes21 commented on June 19, 2024

Thanks for all the help, Greetings from Nicaragua

from graphiql-dotnet.

josephwoodward avatar josephwoodward commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.