Introspection can't use Aliases

Report a GraphQL Bug

What edition and version of Dgraph are you using?

Edition:

  • SlashGraphQL
  • Dgraph (community edition/Dgraph Cloud)

Dgraph Version: v20.11.0-11-gb36b4862

Have you tried reproducing the issue with the latest release?

No.

Steps to reproduce the issue (paste the query/schema if possible)

type Person {
  id: ID
  name: String!
}
type Post {
  id: ID
  title: String
}

Expected behaviour and actual result.

{
  __type(name: "Person") {
    name
  }
}

should return the same results mapped to a different alias as:

{
  Person:__type(name: "Person") {
    name
  }
}

But instead the latter returns null.

This prevents one from doing the following query:

{
  Person:__type(name: "Person") {
    ...typeInfo
  }
  Post:__type(name: "Post") {
    ...typeInfo
  }
}
fragment typeInfo on __Type {
  name
  fields {
    name
    type {
      kind
      name
      ofType {
        kind
        name
      }
    }
  }
}

Which should be a valid schema introspection query.

@chewxy, can you confirm that this should be valid GraphQL Introspection and is indeed a bug?

Hi @verneleem, it’s working on master and 21.03 releases branch. I guess it’s a bug that’s fixed recently.
So,this fix will be reflected in Slash after release 21.03 which is happening this month only.

1 Like

This is still an active bug. An introspection on __type { enumValues { name } } fails as soon as it is aliased.

__Type require argument of type String!.
I tested it on master with this schema.


type Person {
  id: ID
  name: String!
}
type Post {
  id: ID
  title: String
}

enum Book{
	FICTION
	NoN_FICTION
	
}

Introspection enumvalues with Alias

query{
  Book:__type(name: "Book") {
    name
    enumValues{
      name
    }
  }
}

Response

{
  "data": {
    "Book": {
      "name": "Book",
      "enumValues": [
        {
          "name": "FICTION"
        },
        {
          "name": "NoN_FICTION"
        }
      ]
    }
  },

Dgraph Cloud is not running a version with these changes merged.

When is 21.03 going to be live on Dgraph Cloud? I also get errors trying to use dgraph/dgraph:master or dgraph/dgraph:v21.03 with Docker Compose, so I cannot even develop locally while working around this issue.

21.03 will be live on cloud in about 2-3 weeks.

May be some issue with docker-compose, what errors you are getting on it?.

If that’s not working for some reason then you can try building dgraph from source. There you can run on master branch or on 21.03 branch.
GitHub - dgraph-io/dgraph: The high-performance database for modern applications

or you can use dgraph standalone version.
docker run --rm -it -p "8080:8080" -p "9080:9080" -p "8000:8000" -v ~/dgraph:/dgraph "dgraph/standalone:v21.03.0"

1 Like

Replaced latest tag with v21.03.0 for this docker compose:

version: "3.2"
services:
  zero:
    image: dgraph/dgraph:v21.03.0
    volumes:
      - /tmp/data:/dgraph
    ports:
      - 5080:5080
      - 6080:6080
    restart: on-failure
    command: dgraph zero --my=zero:5080
  alpha:
    image: dgraph/dgraph:v21.03.0
    volumes:
      - /tmp/data:/dgraph
    ports:
      - 8080:8080
      - 9080:9080
    restart: on-failure
    command: dgraph alpha --my=alpha:7080 --zero=zero:5080 --whitelist 0.0.0.0/0
  ratel:
    image: dgraph/dgraph:v21.03.0
    ports:
      - 8000:8000
    command: dgraph-ratel
Starting local Dgraph server with Docker.
[sudo] password for christian: 
Building with native build. Learn about native build in Compose here: https://docs.docker.com/go/compose-native-build/
Removing backend_ratel_1
backend_zero_1 is up-to-date
backend_alpha_1 is up-to-date
Recreating 3f44c5b60f05_backend_ratel_1 ... error

ERROR: for 3f44c5b60f05_backend_ratel_1  Cannot start service ratel: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "dgraph-ratel": executable file not found in $PATH: unknown

ERROR: for ratel  Cannot start service ratel: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "dgraph-ratel": executable file not found in $PATH: unknown

Looking into this, I see Ratel was removed from this docker image, so I can remove that service. But now I’m getting errors about the --whitelist flag. Edit: Resolved by replacing --whitespace 0.0.0.0/0 with --security whitespace=0.0.0.0/0.

2 Likes
  dgraph_zero:
    container_name: dgraph_zero
    image: "dgraph/dgraph:latest"
    working_dir: /dgraph
    volumes:
      - ./docker/dev/dgraph:/dgraph
    command:
      - dgraph
      - zero
      - "--my=dgraph_zero:5080"
    ports:
      - "5080:5080"
      - "6080:6080"
    restart: always

  dgraph_alpha:
    container_name: dgraph_alpha
    image: dgraph/dgraph:latest
    working_dir: /dgraph
    volumes:
      - ./docker/dev/dgraph:/dgraph
    ports:
      - "8080:8080"
      - "9080:9080"
    restart: on-failure
    command: dgraph alpha --my=dgraph_alpha:7080 --zero=dgraph_zero:5080

Try it