Document a GraphQL API

后端 未结 5 1340
梦谈多话
梦谈多话 2021-02-02 05:02

With REST we can use Swagger, RAML or other technologies to document our API and generate an HTML documentation that our consumers can read without any need of interaction with

5条回答
  •  旧时难觅i
    2021-02-02 06:03

    Actually Graphql is quite self documented with Facebook's built-in Graphiql or the 3rd party tool like Altair because the queries/mutations are listed and return types are also shown there.

    One place I found need doc is the input query parameter which might require specific format. This can be achieved by adding a comment on top of those arguments.

      type Query {
          eventSearch(
            # comma separated location IDs. (eg: '5,12,27')
            locationIds: String,
            # Date Time should be ISO 8601: 'YYYY-DD-MM HH:mm:ss'. (eg: '2018-04-23 00:00:00')
            startDateTime: String!,
            endDateTime: String!): [Event]
      }
    

    It will be like below:

    Graphiql:

    Graphiql

    Altair:

    Altair

提交回复
热议问题