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

import { BoardViewerPage } from './board-viewer-page'

@customElement('board-viewer-by-name-page')
export class BoardViewerByNamePage extends BoardViewerPage {
  async fetch(name: string) {
    return await client.query({
      query: gql`
        query FetchBoardByName($name: String!) {
          response: boardByName(name: $name) {
            id
            name
            model
          }
        }
      `,
      variables: { name },
      context: gqlContext()
    })
  }
}
