Get GraphQL whole schema query

后端 未结 10 1269
花落未央
花落未央 2020-12-22 23:23

I want to get the schema from the server. I can get all entities with the types but I\'m unable to get the properties.

Getting all types:

query {
  _         


        
10条回答
  •  悲哀的现实
    2020-12-23 00:20

    You can use IntelliJ plugin JS GraphQL then IDEA will ask you create two files "graphql.config.json" and "graphql.schema.json"

    Then you can edit "graphql.config.json" to point to your local or remote GraphQL server:

    "schema": {
    "README_request" : "To request the schema from a url instead, remove the 'file' JSON property above (and optionally delete the default graphql.schema.json file).",
    "request": {
      "url" : "http://localhost:4000",
      "method" : "POST",
      "README_postIntrospectionQuery" : "Whether to POST an introspectionQuery to the url. If the url always returns the schema JSON, set to false and consider using GET",
      "postIntrospectionQuery" : true,
      "README_options" : "See the 'Options' section at https://github.com/then/then-request",
      "options" : {
        "headers": {
          "user-agent" : "JS GraphQL"
        }
      }
    }
    

    After that IDEA plugin will auto load schema from GraphQL server and show the schema json in the console like this:

    Loaded schema from 'http://localhost:4000': {"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"OBJECT","name":"Query","description":"","fields":[{"name":"launche
    

提交回复
热议问题