thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
555 stars 95 forks source link

Enum descriptions and deprecation support #606

Closed mdoelker closed 1 year ago

mdoelker commented 1 year ago

This PR adds support for docblock descriptions for native enums and enum cases, as well as deprecation tag support for cases.

This enum

/**
 * This is the description of the enum itself
 */
enum TestEnum
{
    /**
     * This is a case description
     */
    case FOO;

    /**
     * This is another case description
     * @deprecated it should not be used anymore
     */
    case BAR;
}

results in the following type description in the schema:

{
  "kind": "ENUM",
  "name": "TestEnum",
  "description": "This is the description of the enum itself",
  "specifiedByUrl": null,
  "fields": null,
  "inputFields": null,
  "interfaces": null,
  "enumValues": [
    {
      "name": "BAR",
      "description": "This is another case description",
      "isDeprecated": true,
      "deprecationReason": "it should not be used anymore"
    },
    {
      "name": "FOO",
      "description": "This is a case description",
      "isDeprecated": false,
      "deprecationReason": null
    }
  ],
  "possibleTypes": null
}

GraphiQL output image image

oojacoboo commented 1 year ago

@mdoelker thanks for this - looks great!