import gql from 'graphql-tag'
import { customElement } from 'lit/decorators.js'
import { client, gqlContext } from '@operato/graphql'

import { BoardPlayerPage } from './board-player-page'

@customElement('board-player-by-name-page')
export class BoardPlayerByNamePage extends BoardPlayerPage {
  async fetch(name: string) {
    return await client.query({
      query: gql`
        query ($name: String!) {
          response: playGroupByName(name: $name) {
            id
            name
            description
            boards {
              id
              model
            }
          }
        }
      `,
      variables: {
        name
      }
    })
  }
}
