
# Label Participant / Label Participation - GraphQL Cheatsheet

## Mutations
This is the primary list of mutations to use from[ graphql-participant](https://github.com/theorchard/graphql-participant/blob/63773885b7f18847cfde8984acd0ff8149be243a/src/schema/Mutation.graphql#L2):

```js
type Mutation {
    createLabelParticipant(input: LabelParticipantInput!, vendorId: Int, subaccountId: Int): LabelParticipant! @withSpecificLabel @withPermittedLabels

    """
        Set `LabelSoundRecordingParticipation`s for a `LabelSoundRecording`.

        This mutation deletes current `LabelSoundRecordingParticipation`s and recreates those specified.
    """
    setLabelSoundRecordingParticipations(
        isrc: String!
        vendorId: Int
        subaccountId: Int

        "A list of `LabelSoundRecordingParticipation`s to create. If `participationRoleCategoryName` is set, these MUST have `participationRoleName` set to the name of a `ParticipationRole` from the specified category."
        participations: [LabelSoundRecordingParticipationInput!]!

        "Optionally restrict the operation to only a specific `ParticipationRoleCategory`. If not provided, all participations will be overwritten."
        participationRoleCategoryName: String = null
    ): LabelSoundRecording! @withSpecificLabel @withPermittedLabels @provides(fields: "isrc")

    updateLabelParticipant(id: ID!, input: LabelParticipantInput!, vendorId: Int, subaccountId: Int): LabelParticipant! @withPermittedLabels
}
```

---
## Types
These are some defintions that will explain what's being asked for, and what's being returned.

---

### LabelSoundRecording
This is the isrc object that is modified and (more importantly) returned by the `setLabelSoundRecordingParticipations` mutation.
```js
type LabelSoundRecording @key(fields: "id") {
    id: ID!
    isrc: String! @external
    "Fetch all LabelSoundRecordingParticipations ordered by sequenceNumber."
    participations: [LabelSoundRecordingParticipation]!
    subaccountId: Int!
    vendorId: Int!
}
```

### LabelParticipations (! -ations)
---
#### Input
This takes a uuid from `createLabelParticipant`. Make a list of these for each ISRC.
```js
input LabelSoundRecordingParticipationInput {
    labelParticipantId: ID!
    "The `name` of a `ParticipationRole`."
    participationRoleName: String!
    sequenceNumber: Int!
}
```

---

#### Output
In this case, the uuid is returned as part of the larger LabelParticipant object. (Defined below)
```js
type LabelSoundRecordingParticipation {
    participant: LabelParticipant!
    role: ParticipationRole!
    sequenceNumber: Int!
    soundRecording: LabelSoundRecording!
}
```

---

### LabelParticipant (! -ant)
---
#### Input
This is the input for `createLabelParticipant`. It returns the UUID.
```js
input LabelParticipantInput {
    appleMusicId: String
    name: String!
    spotifyId: String
}
```

---

#### Output
This is the LabelParticipant object in full. You can see the fields that are available here.
```js
type LabelParticipant @key(fields: "uuid") {
    appleMusicId: ID
    artistInfo: [ArtistInfo!] @deprecated(reason: "Support for legacy system")
    globalParticipant: GlobalParticipant
    id: ID! @deprecated(reason: "Use uuid")
    label: Label
    name: String!
    productParticipations: [LabelProductParticipation!]!
    projects: [Project!]!
    soundRecordingParticipations: [LabelSoundRecordingParticipation!]!
    spotifyId: ID
    trackParticipations(filter: LabelTrackParticipationFilterInput): [LabelTrackParticipation!]!
    uuid: ID!
}
```

---
### Other Types
#### ParticipationRole
Definition for a `ParticipationRole`. Has a field for storing DDEX Mappings and uses categories. Is this something we use? 
```js
type ParticipationRole {
    appleRoleName: String
    category: ParticipationRoleCategory!
    ddexRoleName: String
    name: String!
}
```

---
#### ParticipationRoleCategory
This defines a category, and all the roles therein. Used above in `ParticipationRole`.
```js
type ParticipationRoleCategory {
    name: String!
    roles: [ParticipationRole!]!
}
```

---
#### LabelProductParticipation
This looks partially implemented:
```js
type LabelProductParticipation {
    """
        Nullable when a user only has access to specific label participant(s) but not all participants on a product.
    """
    labelParticipant: LabelParticipant

    # TODO participated_as should be deprecated once role is refactored to return an enum
    # lint-disable fields-are-camel-cased
    participated_as: String!
    # lint-enable fields-are-camel-cased

    product: Product!
    role: String! @deprecated(reason: "Use participated_as.")
}
```


---
#### LabelTrackParticipation
This doesn't appear fully implemented:
```js
type LabelTrackParticipation {
    """
        Nullable when a user only has access to specific label participant(s) but not all participants on a track.
    """
    participant: LabelParticipant
    """
        This is the raw value as stored in the database. It has a lot of values and inconsistent space/underscoring.

        For full details, see here.
        https://docs.google.com/spreadsheets/d/1-0jKml4qP5HtunzM0gRUsuN7b-NTBeIFs4aZvMCnWM8/edit#gid=1453061484
    """
    participatedAs: String! @deprecated(reason: "This field should be considered temporary and may change.")
    # lint-disable fields-are-camel-cased
    participated_as: String! @deprecated(reason: "Use participatedAs, this field is an implementation detail")
    # lint-enable fields-are-camel-cased
    track: Track!
}
```