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

Implement aliasing for fields #26

Open
krisgrint opened this issue May 30, 2022 · 3 comments
Open

Implement aliasing for fields #26

krisgrint opened this issue May 30, 2022 · 3 comments

Comments

@krisgrint
Copy link
Contributor

Relates to #11 and the discussion in PR #22

Aliasing of fields in forwarded queries does not appear to be supported out of the box.

Consider the following addition to the test cases in test/proxy.test.js. The first test cases passes, but the second two fail:

{
    name: 'should federate a basic service with queries with aliases on fields',
    services: [
      {
        schema: dedent`
        type Query {
          me: User
        }
        type User {
          id: ID!
          name: String!
          address: String
        }
      `,
        resolvers: {
          Query: {
            me: () => db.users[1]
          },
          User: {
            address: () => 'Banbury'
          }
        }
      }
    ],
    queries: [
      {
        query: '{ me { userId: id, name } }',
        expected: {
          me: {
            userId: '1', // returns the correct aliased field
            name: 'Jimmy'
          }
        }
      },
      {
        query: '{ me { id, firstName: name } }',
        expected: {
          me: {
            userId: '1',
            firstName: 'Jimmy' // returns null for entire me object
          }
        }
      },
      {
        query: '{ me { id, location: address } }',
        expected: {
          me: {
            id: '1',
            location: 'Banbury' // returns null for location
          }
        }
      }
    ]
  }
@Mazuh
Copy link

Mazuh commented Jul 5, 2022

@krisgrint is this still needed or should be already closed after your PR have been merged? is there some work left to be done here that I can help?

@krisgrint
Copy link
Contributor Author

@krisgrint is this still needed or should be already closed after your PR have been merged? is there some work left to be done here that I can help?

Hi @Mazuh no this issue is still to be done - aliasing of the query works, but aliasing of the fields still needs to be implemented.

@Mazuh Mazuh assigned Mazuh and unassigned Mazuh Jul 6, 2022
@Mazuh
Copy link

Mazuh commented Jul 7, 2022

I unassigned myself on this, because I don't have a good time window for it right now. So it is not a WIP.

@ghost ghost assigned ghost and unassigned ghost Sep 5, 2022
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

No branches or pull requests

2 participants