Skip to content

Fix our GraphQL usage (use native variables)Β #5848

Closed

Description

@fregante

GraphQL offers its own variables system. I always avoided it because it was verbose (πŸ€¦β€β™‚οΈ) but it would actually offer a good solution to improper memoization:

Use variables

Before:

api.v4(`
	repository () {
		name
	}
`)

Probably after:

api.v4(`
	repository (owner: $owner, name: $name) {
		name
	}
`, {variables: getRepo()!})

Extract queries to .gql

Separately, I wonder if we could extract these queries to proper GQL files and then import them using a webpack loader.

The best advantage to this would be if there was a typescript transformer that actually parsed these files and provided types.

Webpack would only need to import them as raw text while TypeScript would receive proper types from these files so that we don't need to deal with any πŸ™‚

Formatting and validation would also be nice side effects of this.

Related

Activity

  1. added
    meta
    small
    on Jul 22, 2022
  2. zoey-on-github commented on Feb 22, 2023

    @zoey-on-github

    is anyone else going to do this or can i work on it?

  3. fregante commented on Feb 22, 2023

    @fregante
    MemberAuthor

    You can work on the first part: allow variables. Don't try to fix all the current queries because some aren't possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedmetasmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions