# Basic expand not working on 1st level

**URL:** <https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [November 19, 2020, 2:06pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543 "2020-11-19T14:06:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinyll](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vinyll/32/5415_2.png) [@vinyll](https://discuss.dgraph.io/u/vinyll)\
**Post date:** [November 19, 2020, 2:06pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543/1 "2020-11-19T14:06:03Z")

</div>

Hey Dgraphers,

I’m a newcomer in the Dgraph community!

I’ve been browsing the doc and watching tutorials and I still can figure why my `expand(_all_)` does not return results.  
I’m aware that a `dgraph.type` must be assigned for results to be expanded.

Here’s the actual issue:

```auto
query {
    q(func: type(Therapist)) {
      firstname
      uid
      dgraph.type
    }
  }

```

```auto
{
  "data": {
    "q": [
      {
        "uid": "0x4e22",
        "firstname": "Max-Antoine",
        "dgraph.type": [
          "Therapist"
        ]
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 225300,
      "processing_ns": 9474800,
      "encoding_ns": 33300,
      "assign_timestamp_ns": 30056100,
      "total_ns": 40505900
    },
    "txn": {
      "start_ts": 51460
    },
    "metrics": {
      "num_uids": {
        "_total": 3,
        "dgraph.type": 1,
        "firstname": 1,
        "uid": 1
      }
    }
  }
}

```

## Same with `expand`, no result:

```auto
query {
    q(func: type(Therapist)) {
	expand(_all_)
    }
  }

```

```auto
{
  "data": {
    "q": []
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 792700,
      "processing_ns": 59772200,
      "encoding_ns": 38600,
      "assign_timestamp_ns": 39873100,
      "total_ns": 104427100
    },
    "txn": {
      "start_ts": 51467
    },
    "metrics": {
      "num_uids": {
        "Therapist.agreements": 1,
        "Therapist.airtable_id": 1,
        "Therapist.certified": 1,
        "Therapist.creation": 1,
        "Therapist.description": 1,
        "Therapist.email": 1,
        "Therapist.expiration": 1,
        "Therapist.firstname": 1,
        "Therapist.languages": 1,
        "Therapist.lastname": 1,
        "Therapist.offices": 1,
        "Therapist.payment_types": 1,
        "Therapist.phone": 1,
        "Therapist.photo": 1,
        "Therapist.price": 1,
        "Therapist.slug": 1,
        "Therapist.socials": 1,
        "Therapist.subscription": 1,
        "Therapist.symptoms": 1,
        "Therapist.therapies": 1,
        "Therapist.timetable": 1,
        "_total": 21,
        "dgraph.type": 0
      }
    }
  }
}

```

I would expect the various predicates to be displayed (firstname, lastname…) but it’s an empty result.

I see `dgraph.type` at the very end that says “0” and I suppose it might be related.

Thanks so much for giving a hand to a newcomer, I will very much appreciate a community support 🙂

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [November 19, 2020, 2:24pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543/2 "2020-11-19T14:24:07Z")

</div>

Welcome @vinyll  
In order for `expand(_all_) ` to pick the fields, you need to declare the type in the schema definition. Please create the type `Therapist` with `firstname` and you should see results. You can use Ratel to create types.

---

<div class="post-metadata">

**Author:** ![vinyll](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vinyll/32/5415_2.png) [@vinyll](https://discuss.dgraph.io/u/vinyll)\
**Post date:** [November 19, 2020, 4:26pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543/3 "2020-11-19T16:26:37Z")

</div>

> [@anand](#):
>
> Please create the type `Therapist` with `firstname` and you should see results

Thanks for your prompt help @anand!

I may have missed something here because I feel like I did it create the type “Therapist”.

I have a

```auto
Type Therapist {
  firstname
  lastname
  …
}

```

In the schema. I assume that’s why I can filter `q(func: type(Therapist))` and I can read `"dgraph.type": ["Therapist"]`in the reply when using explicit predicates like `uid` and `firstname`.  
My schema in Ratel also mentions `<Therapist.firstname>: string .`

Can you see something I missed here?

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [November 19, 2020, 4:32pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543/4 "2020-11-19T16:32:19Z")

</div>

Hi @vinyll.  
Your type should look something like this. Please try it out.

```auto
type Therapist {
  Therapist.firstname
  Therapist.lastname
  …
}

```

---

<div class="post-metadata">

**Author:** ![vinyll](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vinyll/32/5415_2.png) [@vinyll](https://discuss.dgraph.io/u/vinyll)\
**Post date:** [November 19, 2020, 5:09pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543/5 "2020-11-19T17:09:36Z")

</div>

Right, the idea was there indeed

```auto
type Therapist {
  Therapist.firstname
  Therapist.lastname
  …
}

```

rose the following error:

```auto
{"errors":[{"message":"line 1 column 0: Unexpected token: lex.Item [6] \"{\" at 1:0 while parsing schema","extensions":{"code":"Error"}}]}

```

However, saving with the following would save in the appropriate subject:

```auto
{
  set {
    _:john <graph.type> "Therapist" .
    _:john <therapist.firstname> "John" .
    _:john <therapist.lastname> "Doe" .
  }
}

```

The error I had done was to create the object with `_:john <firstname> "John" .` instead and that would first create the firstname schema (yes, it creates a schema on its own…) and it would not assign it to the Therapist type, even though `<graph.type> "Therapist"` is mentionned.

That is very confusing… 😕

Anyways, I’m not stuck anymore at least and I can move on my learning now.

Thanks again @anand, that’s **very helpful** not to feel alone with a new tool like this. 👍

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [November 19, 2020, 5:17pm UTC](https://discuss.dgraph.io/t/basic-expand-not-working-on-1st-level/11543/6 "2020-11-19T17:17:05Z")

</div>

Hi @vinyll,  
Happy to help. Please do ping us if you get stuck!
