Giter Site home page Giter Site logo

GraphQL Aliases about graphql-typed-client HOT 4 OPEN

helios1138 avatar helios1138 commented on June 6, 2024
GraphQL Aliases

from graphql-typed-client.

Comments (4)

pierissimo avatar pierissimo commented on June 6, 2024 1

this looks reasonable to me, and also it would be easy to preserve typing and intellisense

client.query({
  originalQueryName: {
    __alias: {
      newQueryName: {
        field: true,
      },
    },
  },
})

from graphql-typed-client.

helios1138 avatar helios1138 commented on June 6, 2024

Aliases are not supported right now, because I couldn't think of a nice syntax that would allow describing aliases in TS, while also preserving auto-completion support :)

Suggestions are welcome

from graphql-typed-client.

Gozala avatar Gozala commented on June 6, 2024

Maybe something along the lines of:

client.aliased.query({
   first: {
      product: [input, {
      }]
   },
  second: {
     product: [input, {
     }]
  }
})

I think at type level it should be possible to turn QR into union of records each containing a single field providing type for the aliased field. Return also could be type mapped to corresponding Qs.

from graphql-typed-client.

Nevvulo avatar Nevvulo commented on June 6, 2024

I've just ran into a situation where I need to use aliases in my query and I would love to see this added. I would've expected something similar to how on_[Model] works at the moment, for example the key would be: alias_[aliased name]_[real field name] (in this case alias_specificProduct_product) and the value would be a normal query object. I understand there's no alias keyword in GraphQL so it may not read like the original but feels intuitive enough to fit into an existing query. But I'm not fussed and I think both suggestions above are good as well 🙂

from graphql-typed-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.