Skip to content

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

@fregante

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedmetaRelated to Refined GitHub itselfsmallIssues that new contributors can pick up

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions