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

feat: add operation alias support #71

Merged
merged 1 commit into from
Jul 21, 2022

Conversation

leeroyrose
Copy link
Contributor

@leeroyrose leeroyrose commented Jul 20, 2022

Adding support for aliases, as per: https://graphql.org/learn/queries/#aliases

@leeroyrose leeroyrose mentioned this pull request Jul 20, 2022
@atulmy
Copy link
Owner

atulmy commented Jul 20, 2022

Thanks for the contribution. Was wondering if following notation would work better and keep the API simpler:

operation: {
  name: 'getNotes',
  alias: `listNotes`
}

Let me know what you think.

@leeroyrose
Copy link
Contributor Author

leeroyrose commented Jul 20, 2022

Agree! I will update my pr to reflect it

@atulmy
Copy link
Owner

atulmy commented Jul 21, 2022

Should work like so:

Without alias:

const query = gql.query({
  operation: 'thought',
  variables: { id: 1 },
  fields: ['id', 'name', 'thought']
})

With alias:

const query = gql.query({
  operation: {
    name: 'thought',
    alias: 'getThoughtById'
  },
  variables: { id: 1 },
  fields: ['id', 'name', 'thought']
})

@leeroyrose
Copy link
Contributor Author

@atulmy I have updated the code to match the proposed notation

interface IQueryBuilderOptions {
operation: string /* Operation name */;
operation: string | IOperation /* Operation name */;
alias?: string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do away with alias key here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, forgot to remove it

@atulmy
Copy link
Owner

atulmy commented Jul 21, 2022

Also add your info in Readme https://github.com/atulmy/gql-query-builder#contributors

@leeroyrose
Copy link
Contributor Author

Done

@leeroyrose leeroyrose requested a review from atulmy July 21, 2022 11:26
@atulmy atulmy merged commit c042064 into atulmy:master Jul 21, 2022
@leeroyrose
Copy link
Contributor Author

Thank you. What is the publish process? Can I expect a release today?

@atulmy
Copy link
Owner

atulmy commented Jul 21, 2022

Published https://www.npmjs.com/package/gql-query-builder/v/3.7.0 🎉

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.

2 participants