Skip to content

mock #66

@artola

Description

@artola

I have the following query, and some troubles to mock it. (using v 3.0.6)

      query trialQuery {
        viewer {
          name
          isHireable
          repository(name: "test") {
            issues(first: 5, orderBy: {field: CREATED_AT, direction: DESC}) {
              pageInfo {
                hasPreviousPage
                hasNextPage
                startCursor
                endCursor
              }
              totalCount
              edges {
                node {
                  id
                  title
                  viewerDidAuthor
                  state
                }
              }
            }
          }
        }
        licenses {
          name
        }
      }
    `;

Situation:

  • without licenses part, it is possible to mock it (removing the "viewer"), e.g.:
{
    isHireable: false,
    name: 'martin',
    repository: {
      issues: {
        pageInfo: {
          hasPreviousPage: false,
          hasNextPage: true,
          startCursor:
            'Y3Vyc29yOnYyOpK5MjAxOS0wMS0xNFQxMDowNTo0NSswMTowMM4XxS65',
          endCursor: 'Y3Vyc29yOnYyOpK5MjAxOS0wMS0xNFQxMDowNDo0MyswMTowMM4XxS1p',
        },
        totalCount: 25,
        edges: [
          {
            node: {
              id: 'MDU6SXNzdWUzOTg3OTg1MjE=',
              title: 'test 25',
              viewerDidAuthor: true,
              state: 'OPEN',
            },
          },
...
  • I would like to have viewer, as it is more semantic, but especially it is necessary if we want to query multiple resources at once, in the example above, no way to mock licenses.

One more thing, if I try to define variables (global), I get an error:

      query trialQuery($repo: String!, $count: Int, $orderBy: IssueOrder) {
        viewer {
          name
          isHireable
          repository(name: $repo) {
            issues(first: $count, orderBy: $orderBy) {
...

Error: repo variable is not defined on viewer arguments

@estrada9166 Could you please give me some hint?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions