Skip to content

Aliases still not works correctly #443

@Fi1osof

Description

@Fi1osof

Related to #176, prisma/prisma#2429 (comment) and other.

Yes, i setted tracing: false and cacheControl: false options and this applyed.

This GraphQL server doesn’t support tracing. See the following page for instructions:
https://github.com/apollographql/apollo-tracing

but aliases still not works.

Query:

query {
  galleries (
    where:{
      id: "ck2q3mf8y14p70a00h2p07gcs"
    }
  ){
    files: Files (
      first: 1
    ){
      id
    }
  }
}

Result:

{
  "data": {
    "galleries": [
      {
        "files": null
      }
    ]
  }
}

Debug:

Response from http://localhost:4466/stage/dev:
{
  "galleries": [
    {
      "files": [
        {
          "id": "ck2q43wvf14tu0a00kdm283p0"
        }
      ]
    }
  ]
}

For additions debuging i add custom resolvers:

  resolvers: {
    ...resolvers,
    Query: {
      ...resolvers.Query,
      galleries: (source, args, ctx, info) => {

        return ctx.db.query.galleries(args, info);
      },
    },
    Gallery: {
      // If got files
      files: (source, args, ctx, info) => {
        const {
          files,
        } = source;

        console.log('files source', JSON.stringify(source, true, 2));

        return files;
      },
      // If got Files
      Files: (source, args, ctx, info) => {
        const {
          Files,
        } = source;

        console.log('Files source', JSON.stringify(source, true, 2));

        const {
          schema,
          ...other
        } = info;

        console.log('Files info', JSON.stringify(other, true, 2));

        return Files;
      },
    },
  },

Result:

Files source {
  "files": [
    {
      "id": "ck2q43wvf14tu0a00kdm283p0"
    }
  ]
}
Files info {
  "fieldName": "Files",
  "fieldNodes": [
    {
      "kind": "Field",
      "alias": {
        "kind": "Name",
        "value": "files",
        "loc": {
          "start": 62,
          "end": 67
        }
      },
      "name": {
        "kind": "Name",
        "value": "Files",
        "loc": {
          "start": 69,
          "end": 74
        }
      },
      "arguments": [
        {
          "kind": "Argument",
          "name": {
            "kind": "Name",
            "value": "first",
            "loc": {
              "start": 75,
              "end": 80
            }
          },
          "value": {
            "kind": "IntValue",
            "value": "1",
            "loc": {
              "start": 82,
              "end": 83
            }
          },
          "loc": {
            "start": 75,
            "end": 83
          }
        }
      ],
      "directives": [],
      "selectionSet": {
        "kind": "SelectionSet",
        "selections": [
          {
            "kind": "Field",
            "name": {
              "kind": "Name",
              "value": "id",
              "loc": {
                "start": 93,
                "end": 95
              }
            },
            "arguments": [],
            "directives": [],
            "loc": {
              "start": 93,
              "end": 95
            }
          }
        ],
        "loc": {
          "start": 85,
          "end": 101
        }
      },
      "loc": {
        "start": 62,
        "end": 101
      }
    }
  ],
  "returnType": "[File!]",
  "parentType": "Gallery",
  "path": {
    "prev": {
      "prev": {
        "key": "galleries"
      },
      "key": 0
    },
    "key": "files"
  },
  "fragments": {},
  "operation": {
    "kind": "OperationDefinition",
    "operation": "query",
    "variableDefinitions": [],
    "directives": [],
    "selectionSet": {
      "kind": "SelectionSet",
      "selections": [
        {
          "kind": "Field",
          "name": {
            "kind": "Name",
            "value": "galleries",
            "loc": {
              "start": 4,
              "end": 13
            }
          },
          "arguments": [
            {
              "kind": "Argument",
              "name": {
                "kind": "Name",
                "value": "where",
                "loc": {
                  "start": 14,
                  "end": 19
                }
              },
              "value": {
                "kind": "ObjectValue",
                "fields": [
                  {
                    "kind": "ObjectField",
                    "name": {
                      "kind": "Name",
                      "value": "id",
                      "loc": {
                        "start": 22,
                        "end": 24
                      }
                    },
                    "value": {
                      "kind": "StringValue",
                      "value": "ck2q3mf8y14p70a00h2p07gcs",
                      "block": false,
                      "loc": {
                        "start": 26,
                        "end": 53
                      }
                    },
                    "loc": {
                      "start": 22,
                      "end": 53
                    }
                  }
                ],
                "loc": {
                  "start": 21,
                  "end": 54
                }
              },
              "loc": {
                "start": 14,
                "end": 54
              }
            }
          ],
          "directives": [],
          "selectionSet": {
            "kind": "SelectionSet",
            "selections": [
              {
                "kind": "Field",
                "alias": {
                  "kind": "Name",
                  "value": "files",
                  "loc": {
                    "start": 62,
                    "end": 67
                  }
                },
                "name": {
                  "kind": "Name",
                  "value": "Files",
                  "loc": {
                    "start": 69,
                    "end": 74
                  }
                },
                "arguments": [
                  {
                    "kind": "Argument",
                    "name": {
                      "kind": "Name",
                      "value": "first",
                      "loc": {
                        "start": 75,
                        "end": 80
                      }
                    },
                    "value": {
                      "kind": "IntValue",
                      "value": "1",
                      "loc": {
                        "start": 82,
                        "end": 83
                      }
                    },
                    "loc": {
                      "start": 75,
                      "end": 83
                    }
                  }
                ],
                "directives": [],
                "selectionSet": {
                  "kind": "SelectionSet",
                  "selections": [
                    {
                      "kind": "Field",
                      "name": {
                        "kind": "Name",
                        "value": "id",
                        "loc": {
                          "start": 93,
                          "end": 95
                        }
                      },
                      "arguments": [],
                      "directives": [],
                      "loc": {
                        "start": 93,
                        "end": 95
                      }
                    }
                  ],
                  "loc": {
                    "start": 85,
                    "end": 101
                  }
                },
                "loc": {
                  "start": 62,
                  "end": 101
                }
              }
            ],
            "loc": {
              "start": 56,
              "end": 105
            }
          },
          "loc": {
            "start": 4,
            "end": 105
          }
        }
      ],
      "loc": {
        "start": 0,
        "end": 107
      }
    },
    "loc": {
      "start": 0,
      "end": 107
    }
  },
  "variableValues": {}
}

Data exists, and alias info exists:

  "fieldNodes": [
    {
      "kind": "Field",
      "alias": {
        "kind": "Name",
        "value": "files",
        "loc": {
          "start": 62,
          "end": 67
        }
      },
      "name": {
        "kind": "Name",
        "value": "Files",
        "loc": {
          "start": 69,
          "end": 74
        }
      },

But resolver do not returns data correctly.

For workaround i added in resolver:

        if(files !== undefined){
          return files;
        }

but this is not cool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions