How to expose graphql field with different name

You can use GraphQL Aliases to modify individual keys in the JSON response.

If this is your original query

query {
  POJO {
    id
    name
  }
}

you can introduce a GraphQL alias userName for the field name like so:

query {
  POJO {
    id
    userName: name
  }
}

You can also use GraphQL aliases to use the same query or mutation field multiple times in the same GraphQL operation. This gets especially interesting when using field parameters:

query {
  first: POJO(first: 1) {
    id
    name
  }

  second: POJO(first: 1, skip: 1) {
    id
    name
  }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)