Skip to content

About

Phoenix application using Absinthe GraphQL

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

39 Commits

Folders and files

Repository files navigation

Phoenix Application GraphQL API using Absinthe

Dependencies

  • Elixir 1.11.3 (compiled with Erlang/OTP 23)
  • Phoenix - 1.5.7
  • Absinthe - 1.4
  • PostgreSQL - 13.1

Install the project

$ git clone git@github.com:betocattani/nfl-rushing.git

To config the Phoenix application:

  • $ cd nfl-rushing
  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server

Populate database with the file rushing.json

$ iex -S mix
iex> TheScore.ImportPlayers.import("dev/support/rushing.json")

Access the GraphQL Playground

Now you can visit localhost:4000 from your browser

List all Players

{
  players {
    name
    position
    rushingAttempts
    rushingAttemptsPerGameAvg
    rushingAverageYardsPerAttempt
    rushingFirstDownPercentageFirst
    rushingFirstDowns
    rushingFumbles
    rushingYardsEachFortyPlus
    rushingYardsEachTwentyPlus
    rushingYardsPerGame
    team
    totalRushingTouchdowns
    totalRushingYards
  }
}

Mutatation to create a new Player

mutation {
  createProfile(
    longestRush: "3",
    name: "Periclao",
    position: "AT",
    rushingAttempts: "6",
    rushingAttemptsPerGameAvg: "3",
    rushingAverageYardsPerAttempt: "3.7",
    rushingFirstDownPercentageFirst: "3",
    rushingFirstDowns: "1",
    rushingFumbles: "9",
    rushingYardsEachFortyPlus: "3",
    rushingYardsEachTwentyPlus: "2",
    rushingYardsPerGame: "9",
    team: "Phoenix",
    totalRushingTouchdowns: "1",
    totalRushingYards: "8"
  ) {
    name
    position
    rushingAttempts
    rushingAttemptsPerGameAvg
    rushingAverageYardsPerAttempt
    rushingFirstDownPercentageFirst
    rushingFirstDowns
    rushingFumbles
    rushingYardsEachFortyPlus
    rushingYardsEachTwentyPlus
    rushingYardsPerGame
    team
    totalRushingTouchdowns
    totalRushingYards
  }
}

or

Creates a new Player using query variables

mutation ($playerProfile: PlayerProfileInput!) {
  createPlayerProfile(input: $playerProfile) {
    errors {
      key
      message
    }
    playerProfile {
      name
      team
      position
    }
  }
}

// query variables
{
  "playerProfile": {
    "name": "Joao bosco",
    "team": "bentao",
    "position": "midle"
  }
}

Find players using filter by name

{
  players(filter: {name: "Luiz Cattani"}) {
    name
    position
    rushingAttempts
    rushingAttemptsPerGameAvg
    rushingAverageYardsPerAttempt
    rushingFirstDownPercentageFirst
    rushingFirstDowns
    rushingFumbles
    rushingYardsEachFortyPlus
    rushingYardsEachTwentyPlus
    rushingYardsPerGame
    team
    totalRushingTouchdowns
    totalRushingYards
  }
}

Find players using filter in query variables

Availables filters: [name / totalRushingYards / longestRush / totalRushingTouchdowns]

query ($filter: PlayerProfileFilter!) {
  players(filter: $filter, order: DESC) {
    name
    position
    rushingAttempts
    rushingAttemptsPerGameAvg
    rushingAverageYardsPerAttempt
    rushingFirstDownPercentageFirst
    rushingFirstDowns
    rushingFumbles
    rushingYardsEachFortyPlus
    rushingYardsEachTwentyPlus
    rushingYardsPerGame
    team
    totalRushingTouchdowns
    totalRushingYards
  }
}

// Query Variables
{
  "filter": {
    "name": "Kevin"
    "totalRushingYards": "8",
    "longestRush": "3",
    "totalRushingTouchdowns": "1"
  }
}

// or

{"filter": {}}

About

Phoenix application using Absinthe GraphQL

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages