Skip to content

alex-user-go/art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ART

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.

Not invented here

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

Examples:

Adding:

mutation {
  addArtwork(title: "44", artistID: 1) {
    id
    title
    artist {
      name
    }
  }
}
mutation {
  addArtist(name: "6655") {
    name
  }
}

Updating:

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
    }
  }
}

Deleting:

mutation {
  deleteArtwork(id: 1)
}
mutation {
  deleteArtist(id: 2)
}

Querying:

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
    }
  }
}

About

A simple project to use graphql

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages