Skip to content
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

Create common fragments #5

Open
mattkrick opened this issue Feb 8, 2022 · 0 comments
Open

Create common fragments #5

mattkrick opened this issue Feb 8, 2022 · 0 comments

Comments

@mattkrick
Copy link
Member

look at this

  repository_2: repository(owner: \"ParabolInc\", name: \"parabol\") {
    issue(number: 5811) {
      __typename
      ... on Issue {
        __typename
        title
        number
      }
      id
      __typename
      id
      __typename
      id
      __typename
      ... on Issue {
        __typename
        repository {
          nameWithOwner
          id
        }
      }
      id
      __typename
      id
      __typename
      ... on Issue {
        __typename
        ...PokerEstimateHeaderCardGitHub_issue
      }
      id
    }
  }
  repository_4: repository(owner: \"ParabolInc\", name: \"parabol\") {
    issue(number: 5812) {
      __typename
      ... on Issue {
        __typename
        title
        number
      }
      id
      __typename
      id
      __typename
      id
      __typename
      ... on Issue {
        __typename
        repository {
          nameWithOwner
          id
        }
      }
      id
      __typename
      id
      __typename
      ... on Issue {
        __typename
        ...PokerEstimateHeaderCardGitHub_issue
      }
      id
    }
  }

these 2 are identical except for the varDefs.
we should make these become the following:

fragment issue1 on Issue {
   __typename
      ... on Issue {
        __typename
        title
        number
      }
      id
      __typename
      id
      __typename
      id
      __typename
      ... on Issue {
        __typename
        repository {
          nameWithOwner
          id
        }
      }
      id
      __typename
      id
      __typename
      ... on Issue {
        __typename
        ...PokerEstimateHeaderCardGitHub_issue
      }
      id
}
  repository_2: repository(owner: \"ParabolInc\", name: \"parabol\") {
    issue(number: 5811) {
        ...issue1
    }
  }
  repository_4: repository(owner: \"ParabolInc\", name: \"parabol\") {
    issue(number: 5812) {
        ...issue1 
    }
  }

i think this is easy to do using the wrapper param.
it plays with #2 nicely, too.
basically instead of inlining ...info we do the following:

  • create a fragment for ...info
  • replace ...info with ...info1 (or whatever it is)
  • make sure that the info object is the same every time & then just dont' create that fragment next time

then, when it comes up again,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant