Cannot query field "_service" on type "Query"

Hi,
I am currently attempting to use apollo gateway, server, and federation to connect to a running dgraph instance. The dgraph instance is running in docker following this command:
docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph --name dgraph dgraph/standalone:v21.03.0

I am then filling the graphql schema according to the graphql getting started docs using curl and the following schema:

type Product {
    productID: ID!
    name: String @search(by: [term])
    reviews: [Review] @hasInverse(field: about)
}

type Customer {
    username: String! @id @search(by: [hash, regexp])
    reviews: [Review] @hasInverse(field: by)
}

type Review {
    id: ID!
    about: Product!
    by: Customer!
    comment: String @search(by: [fulltext])
    rating: Int @search
}

I am encountering an error when trying to connect to the graphql url for dgraph from apollo gateway:

Cannot query field "_service" on type "Query"

It seems related to the federation standard.
Do I need to create this service when creating the schema I pass to dgraph?

Thanks!

I moved this to a new topic.

@Tyler_D can you tell me what version of Dgraph you are using?

Hi @Tyler_D, You have not defined any entity in your graphql schema. This schema is equivalent to a blank schema to the gateway. According to our implementation if there is no entity in the schema then Apollo federation resolvers are excluded which is resulting in error. You need to define at least one entity in your schema to make use of federation. For example, if you change your type Review definition to this:-

type Review @key(fields: "id"){
    id: ID!
    about: Product!
    by: Customer!
    comment: String @search(by: [fulltext])
    rating: Int @search
}

then there should be no issue. Feel free to ask further questions.

2 Likes