0
By doing so :
const GROUP_QUERY = gql`
query groupQuery ($id: ID) {
record: group (id: $id) {
id
name
usersCount
userIds {
id
username
}
}
}
`
If the GROUP_QUERY
is used at several places, the result will be accessible under the record
name, because it is defined as an alias over group
.
See documentation for Aliases.
0
You can, in fact, rename the variable of Apollo smart queries using the update
option, as seen here in the Vue Apollo documentation. Your example would look like:
apollo: {
record: {
query: GROUP_QUERY,
variables () { return { id: this.groupId } },
update: (data) => data.group,
skip () { return this.groupId === undefined },
result ({ data }) {
this.form.name = data.group.name
}
}
}
You should notice that the Apollo object will create a record
variable in your component, and the update
statement shows where to get the group
for the record.
Source:stackexchange.com