WPGraphQL provides support for querying Media Items, what WordPress calls “attachments”.
WPGraphQL supports querying Media Items in various ways.
Below are some common examples of querying Media Items with WPGraphQL.
Below is an example of querying a list of media items.
Below is an example of querying a Media Item using its Global ID.
If you have the source url for an image in the media library, you can use that as a unique identifier for querying an Media Item.
Below is an example of querying a Post using its Database ID, and its connected Featured Image.
The connection between the Post and Featured image is a good example of a one-to-one connection.
NOTE: WPGraphQL supports mutations for the data stored in the Database for Media Items, but WPGraphQL does not (yet) provide a way to handle the actual uploads of files. See open issues related to this topic.