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

fix: Get query's operation name from vars (#64) #165

Closed
wants to merge 15 commits into from

Conversation

adebisi-fa
Copy link

Given the following query:

query HeroName {
  hero {
    name
  }
}

query HeroNameAndFriends {
  hero {
    name
    friends {
      name
    }
  }
}

mutation CreateNewHero($name: String) {
  hero {
      createNewHero(name: $name) {
         id
         name
      }
  }
}

With this pull request, HeroName can be called viz:

request(serverUrl, query, { __operation: 'HeroName' });

or, as:

// Configure a custom key for `operationName`
var client = new GraphqlClient(serverUrl, { operationNameKey: '$operationName' });

// Make a request with the custom key
client.request(query, { $operationName: 'HeroName' });

The mutation CreateNewHero can be called viz:

request(serverUrl, query, { __operation: 'CreateNewHero', name: "New Hero Name" });

Notice how the name variable played along with the __operation variable.

Hope this helps.

@adebisi-fa adebisi-fa changed the title * Get query's operation name from vars, fixes #64 fix: Get query's operation name from vars #64 May 27, 2020
@adebisi-fa adebisi-fa mentioned this pull request May 27, 2020
brikou and others added 14 commits May 27, 2020 21:58
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>

closes graffle-js#26
closes graffle-js#100 (superseded)
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>

BREAKING CHANGE:

You are responsible for polyfilling your environment with `cross-fetch` if needed now.
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>
This removes the export of Options as they no longer exist and so were a
bug to be exporting.
@adebisi-fa adebisi-fa changed the title fix: Get query's operation name from vars #64 fix: Get query's operation name from vars (#64) May 28, 2020
@bobh66
Copy link

bobh66 commented Aug 20, 2020

Bump - this would be really useful to have.

@jasonkuhrt
Copy link
Member

Hey @adebisi-fa please rebase and I'll try to get this merged soon

@jasonkuhrt jasonkuhrt deleted the branch graffle-js:master January 26, 2023 02:00
@jasonkuhrt jasonkuhrt closed this Jan 26, 2023
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

Successfully merging this pull request may close these issues.

9 participants