tboothman / imdbphp

PHP library for retrieving film and tv information from IMDb
251 stars 84 forks source link

imdb graphQL possibleTypes #315

Closed duck7000 closed 1 year ago

duck7000 commented 1 year ago
{
  "data": {
    "__type": {
      "kind": "INTERFACE",
      "name": "Credit",
      "description": "Credit details. Open question: do we want to add a persistent ID for credits?\nWithout this we require a nameID, titleID and Category to uniquely identify it.",
      "fields": [
        {
          "name": "attributes",
          "description": "Miscellaneous attributes (e.g. 'Archive Footage')",
          "args": [
            {
              "name": "limit",
              "description": null,
              "type": {
                "kind": "SCALAR",
                "name": "Int",
                "ofType": null
              },
              "defaultValue": null
            }
          ],
          "type": {
            "kind": "LIST",
            "name": null,
            "ofType": {
              "kind": "NON_NULL",
              "name": null,
              "ofType": {
                "kind": "INTERFACE",
                "name": "CreditAttribute",
                "ofType": null
              }
            }
          },
          "isDeprecated": true,
          "deprecationReason": "Attributes field should be fetched from Crew or Cast" // how does this work?
        },
        {
          "name": "category",
          "description": "Category (e.g. 'Producer').\nOpen question: the name of this field comes from TitleCreditsBaseV5. Should we change it?",
          "args": [],
          "type": {
            "kind": "NON_NULL",
            "name": null,
            "ofType": {
              "kind": "OBJECT",
              "name": "CreditCategory",
              "ofType": null
            }
          },
          "isDeprecated": false,
          "deprecationReason": null
        },
        {
          "name": "name",
          "description": "The person credited",
          "args": [],
          "type": {
            "kind": "NON_NULL",
            "name": null,
            "ofType": {
              "kind": "OBJECT",
              "name": "Name",
              "ofType": null
            }
          },
          "isDeprecated": false,
          "deprecationReason": null
        },
        {
          "name": "title",
          "description": "The title on which this credit appears",
          "args": [],
          "type": {
            "kind": "NON_NULL",
            "name": null,
            "ofType": {
              "kind": "OBJECT",
              "name": "Title",
              "ofType": null
            }
          },
          "isDeprecated": false,
          "deprecationReason": null
        }
      ],
      "inputFields": null,
      "interfaces": [],
      "enumValues": null,
      "possibleTypes": [
        {
          "kind": "OBJECT",
          "name": "Cast",
          "ofType": null
        },
        {
          "kind": "OBJECT",
          "name": "Crew",
          "ofType": null
        }
      ]
    }
  },
  "extensions": {
    "disclaimer": "Public, commercial, and/or non-private use of the IMDb data provided by this API is not allowed. For limited non-commercial use of IMDb data and the associated requirements see https://help.imdb.com/article/imdb/general-information/can-i-use-imdb-data-in-my-software/G5JTRESSHJBBHTGX#"
  }
}

De question is how does possibleTypes work? I'm trying to get attributes from credits/director for example but attributes is stated as deprecated and suggestion is to use Crew but how does that work inside the query for, in this example, Director? I can't figure this one out..

So far this query works but without attributes:

query CreditQuery(\$id: ID!) {
  title(id: \$id) {
    credits(first: 9999, filter: { categories: ["director"] }) {
      edges {
        node {
          name {
            nameText {
              text
            }
            id
          }
        }
      }
    }
  }
}
EOF;
duck7000 commented 1 year ago

@tboothman do you have any idea how this works?

I get the feeling that possibleTypes might be like title or name?

Edit: i found this but this info might be old?, check creditsByCategory https://developer.imdb.com/documentation/bulk-data-documentation/data-dictionary/titles/