Skip to content

Add Events to API #747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 8, 2019
Merged

Add Events to API #747

merged 3 commits into from
Oct 8, 2019

Conversation

connorshea
Copy link
Owner

Part of #735.

This adds events to the API as well as an activity endpoint that you can use to list events either in the 'following' scope or 'global' scope.

query testActivity {
  activity(feedType: GLOBAL) {
    user {
      username
    }
    eventCategory
  }
}

You can also list events for a given user. Because Events have a polymorphic relationship with the 'eventable', you have to do some special stuff to get data from them.

query ($id: ID!) {
  user(id: $id) {
    avatarUrl
    id
    username
    events {
      id
      user {
        username
      }
      eventCategory
      eventable {
        ... on User {
          __typename
          username
        }
        ... on Relationship {
          __typename
          follower {
            username
          }
          followed {
            username
          }
        }
        ... on GamePurchase {
          __typename
          game {
            name
          }
        }
        ... on FavoriteGame {
          __typename
          game {
            name
          }
        }
      }
    }
  }
}

@connorshea connorshea merged commit 7af3168 into master Oct 8, 2019
@connorshea connorshea deleted the add-events-to-api branch October 8, 2019 03:43
@connorshea connorshea added the api GraphQL API-related issues and PRs label Oct 11, 2019
@connorshea connorshea mentioned this pull request Oct 12, 2019
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api GraphQL API-related issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant