A simple GraphQL server for managing artists and artworks. An artist has a name and a set of artworks, each artwork has a title. Artwork can only belong to a single artist.
This repo was inspired by the great Kat Zien speech (GopherCon 2018).
GraphQl mutations are based on the Anemic Mutations, allowing users to update any field independently without optional fields
mutation {
addArtwork(title: "44", artistID: 1) {
id
title
artist {
name
}
}
}
mutation {
addArtist(name: "6655") {
name
}
}
mutation {
updateArtist(id: 1, actions: { setName: { name: "newname" } }) {
name
}
}
mutation {
updateArtwork(
id: 1
actions: { setTitle: { title: "newtitle" }, setArtist: { artistID: 5 } }
) {
id
title
artist {
name
id
}
}
}
mutation {
deleteArtwork(id: 1)
}
mutation {
deleteArtist(id: 2)
}
To query all artists:
query {
filterArtists(name: "") {
name
id
}
}
To filter artists:
query {
filterArtists(name: "partOfTheName") {
name
id
}
}
Artist's artworks
query {
artist(id: 1) {
artworks {
title
id
}
}
}