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

Aliases still not works correctly #443

Open
Fi1osof opened this issue Dec 19, 2019 · 0 comments
Open

Aliases still not works correctly #443

Fi1osof opened this issue Dec 19, 2019 · 0 comments

Comments

@Fi1osof
Copy link

Fi1osof commented Dec 19, 2019

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.

  • prisma-binding@2.3.16
  • graphql-yoga@1.18.3
  • prismagraphql/prisma:1.34
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

1 participant