How can I return all nodes of a certain type?

I have just made my first inserts with the Go client, and the data is being inserted

I can query like this by the latest inserted uid and I get the data from this node :

{
  node(func: uid(0x49)) {
    expand(DummyType)
  }
}

This returns the json with all the data from the type I’m expanding on the query by the uid

But I can’t find the way of returning all nodes of a certain type :

{
  q(func: type(DummyType)) {
    expand(all)
  }
}

When I do this nothing is returned … How can I get all the nodes of a type returned with all the type fields expanded ?

Try

{
  q(func: type(DummyType)) {
    expand(_all_)
  }
}

Don’t miss the underscores at the beginning and the end of _all_.

doesn’t work

schema := `
type DummyType {
	name: string
  }
`

op := &api.Operation{
	Schema: schema,
}
ctx := context.Background()

if err := u.dgraphClient.GetClient().Alter(ctx, op); err != nil {
	return nil, err
}

mutator := dgraph.NewMutator(u.dgraphClient)

response, err := mutator.Mutate(struct)
if err != nil {
	return nil, err
}
return response, nil

this is what I’m doing. The data gets inserted but I just can’t query by type. With queries that don’t require a type I’m able to retrieve all data. Maybe I’m missing something on the type schema ? But the type is actually in there, the Ratle interface lets me auto-complete with it.

You might not have included the type of each node when inserting it. You can check by querying for dgraph.type

{
  q(func: uid(<some_uid>)) {
    uid
    dgraph.type
  }
}

So your type definition in Go should look something like the following:

type Person struct {
	UID         string                 `json:"uid,omitempty"`
    Name        string                 `json:"name,omitempty"`
	DgraphType  []string               `json:"dgraph.type,omitempty"`
}