graphql-java / tutorials

MIT License
211 stars 398 forks source link

Tutorial book-details is not working #3

Closed StephanPraetsch closed 5 years ago

StephanPraetsch commented 5 years ago

Hi there,

I'm playing with https://github.com/graphql-java/tutorials/tree/master/book-details but there's something broken: It starts but does not provide the schema on http://localhost:8080/graphql instead it answers

There was an unexpected error (type=Bad Request, status=400).
Required String parameter 'query' is not present

Might you fix this? Or am I doing something wrong? I only cloned and started.

Kind regards Stephan

mlrgoh commented 5 years ago

Hi Stephan,

Like you I was playing with the book-details tutoriaal and encountered similar issue too.

At first I thought the http:/localhost:8080/graphql endpoint comes with the GraphiQL UI, it doesn't seem like that is the case. That endpoint is purely a GraphQL API. So, you'll need to download GraphQL Playground and enter the http:/localhost:8080/graphql endpoint when asked. It works a treat!

The tutorial does provide the information. For some reasons, I missed it.

Hope this helps.

Cheers Richard Goh

StephanPraetsch commented 5 years ago

Gosh, thanks. I was pretty sure I tried this out. Obviously I didn't ...

But where does the schema and doc come from that GraphQL Playground is able to display?

mlrgoh commented 5 years ago

I'm new to GraphQL too. Good question. So, I did a bit of digging too.

Thanks to the benefit of GraphQL's Type System. We can actually ask the GraphQL schema for information about the queries it supports via introspection query. See https://graphql.org/learn/introspection/ for further details.

I tried the introspect query and it does work. Here is the example introspect query string: curl localhost:8080/graphql?query=%7B__schema%20%7B%20types%20%7Bname%7D%20%7D%7D

StephanPraetsch commented 5 years ago

Ah thanks a lot. I completely misinterprete the tutorial with that /graphql endpoint. Maybe someone should add some more detail how to get the schema. At least I was pretty confused.

atulaa1 commented 3 years ago

Ah thanks a lot. I completely misinterprete the tutorial with that /graphql endpoint. Maybe someone should add some more detail how to get the schema. At least I was pretty confused.

I was confused too. I recommend you use Altair client for grapql query from client. It support many platforms. https://altair.sirmuel.design/ I used chrome extension for test my localhost grapql

anamikabivera commented 3 years ago

Postman has GrapghQL now. After providing the query in GraphQl tab give a POST request.