cajuncoding / GraphQL.RepoDB

A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that encapsulate all data access (without dependency on IQueryable and execution outside of the devs control).
MIT License
40 stars 5 forks source link

How to view the schema? #5

Closed ZedZipDev closed 3 years ago

ZedZipDev commented 3 years ago

I have built and run StarWars-AzureFunctions-RepoDB server , then run

  1. http://localhost:7071/api/graphql {"errors":[{"message":"Either the parameter query or the parameter id has to be set.","extensions":{"code":"HC0013"}}]}

  2. http://localhost:7071/api/graphql/playground/ No any schema. How to view the schema and run a query?

cajuncoding commented 3 years ago

@Oleg26Dev

  1. In question number 1, if you are seeing that error Either the parameter query or the parameter id has to be set., I can only assume that is in the browser window (since you didn't submit any screenshot or context). That means that you are using that endpoint incorrectly.

    • The /api/graphql endpoint is the query engine and is not a valid web uri. It's telling you that you have not provided the parameter named query which is required in order to execute it.
    • Therefore to use that in the browser you must provide a a well formed, encoded, graphql query in the query string because the browser will only use a GET request. And, generally that's not what you'd want to use as you'll likely want to use a POST request and a valid GraphQL client or IDE as below...
    • image
  2. To view the Schema and/or run a query you should use a GraphQL IDE... HotChocolate provides a built in IDE named "Banana Cake Pop" that is available on the endpoint /api/graphql/playground.

    • That is the url you should enter into a browser and it will load the IDE.
    • Then it's very important that you check that the GraphQL engine API is correct which must be set to the endpoint `/api/graphql' in the tab inside of Banana Cake Pop; by default it loads the url from the browser but that is different in my example due to how Azure Functions must work.
    • image
  3. Finally, per your question about the Schema, it's not clear if you were looking to browse it via the IDE (as shown above in number 2 above) or download the raw schema definition, which is also supported via HotChocolates query string param ?sdl (a documented feature of HC):

    • image
ZedZipDev commented 3 years ago

Thank you, I see, the matter is the Banana Cake Pop IDE substituted the same link to its Page Tab too, i.e. /api/graphql/playground But the 2nd one should be /api/graphql/ Now I see the schema.