Skip to content

Commit

Permalink
fix: correct handling of GraphQL aliases in queries
Browse files Browse the repository at this point in the history
Ensure proper functionality of GraphQL aliases within queries.

Example:
Fixed issue where aliases were not correctly resolving in the following query:

```gql
query {
  firstUser: user(id: 1) {
    fullName: name
    email
  }
}
```
  • Loading branch information
schettn committed Jul 9, 2024
1 parent 4de34b0 commit 72e1eed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/pylon/src/define-pylon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ const resolversToGraphQLResolvers = <Q, M>(
asyncContext.enterWith(configuredCtx)
}

// Get the path and field metadata for the current query.
const path = info.path

// get query or mutation field

const isQuery = info.operation.operation === 'query'
Expand All @@ -286,7 +283,7 @@ const resolversToGraphQLResolvers = <Q, M>(
? info.schema.getQueryType()
: info.schema.getMutationType()

const field = type?.getFields()[path.key]
const field = type?.getFields()[info.fieldName]

// Get the list of arguments expected by the current query field.
const fieldArguments = field?.args || []
Expand All @@ -312,7 +309,10 @@ const resolversToGraphQLResolvers = <Q, M>(

// Find the selection set for the current field.
for (const selection of info.operation.selectionSet.selections) {
if (selection.kind === 'Field' && selection.name.value === path.key) {
if (
selection.kind === 'Field' &&
selection.name.value === info.fieldName
) {
baseSelectionSet = selection.selectionSet?.selections || []
}
}
Expand Down

0 comments on commit 72e1eed

Please sign in to comment.