When running standalone. How to add schema via App?

Hey all.

I’m running the standalone docker image, here is my command:

docker run -it -p 9000:8080 --rm -v /Users/paul/Share/development/dgraph/data:/dgraph --name dgraph dgraph/standalone:latest

First question, is there a cloud UI style app when working with graphQL available? I haven’t seen anything in the docs. I’m guessing no because there is a push for people to use the cloud service?

If not, then is my best bet using something like graph.playground or altair?

I’m trying both apps and when trying to add a schema I keep on getting:

{
  "errors": [
    {
      "message": "while lexing {\"query\":\"type BoxToken {\\n  id: ID!\\n  type: String\\n  accessToken: String\\n  expiresIn: String\\n  createdAt: DateTime!\\n  updatedAt: DateTime\\n  deletedAt: DateTime\\n}\",\"variables\":{},\"operationName\":null} at line 1 column 1: Invalid schema. Unexpected \"",
      "extensions": {
        "code": "Error"
      }
    }
  ]
}

Works if I do this via CURL. Is the only way to use CURL? I notice in the documentation that it mentions alternatives such as Altair, etc. But when wanting to manage the schema, it points to CURL. The language used doesn’t say whether CURL is mandatory or not…

When using an APP. If I look at the server, I get:

I0101 14:27:42.686097      27 server.go:1824] Got Alter request from: "172.17.0.1:57048"
I0101 14:27:42.689196      27 server.go:575] ALTER op: schema:"{\"operationName\":null,\"variables\":{},\"query\":\"type BoxToken {\\n  id: ID!\\n  xid: String! @search(by: [exact])\\n  type: String\\n  accessToken: String\\n  expiresIn: String\\n  createdAt: DateTime!\\n  updatedAt: DateTime\\n  deletedAt: DateTime\\n}\\n\"}"  done

Now I am confused. Is it working or not?

Final question. How do I see the entire schema?

Many Thanks

You can use any GraphQL playground, I recently started using Apollo Studio. And then point it at the admin endpoint to update the schema or point it at the graphql endpoint to introspect the current schema and run queries mutations

1 Like

Thanks for the reply, but I don’t know what the correct endpoint is.

Looking at my docker startup, can you tell me whether I have the correct ports running and what the endpoint should be?

The endpoints are

localhost:8080/graphql for the DB
localhost:8080/admin for administration operations

I’m running localhost:9000/alter to change the schema

But it doesn’t work.

Alter endpoint is DQL only. GraphQL you do schema alterations via /admin endpoint. All this are in the docs and the tutorials.

This I was getting before. I’ve now switched to using curl.

It is via cURL that you do this. You can do it via some IDE or GraphQL client, but you need more experience in GraphQL to do so. Cuz you need to parse the schema before send the Schema mutation. Keep it simple via cURL.

https://dgraph.io/docs/graphql/quick-start/#step-2---add-a-graphql-schema

Thanks, this is what I was looking for. In the documents it mentions right before using CURL. That there are other apps. So there is some ambiguity here.

It would be helpful to new users like me, who are not going down the traditional cloud route. That CURL is the only way to go. It should be more direct. :grinning:

The admin endpoint is graphql so you would need to run a mutation to set the schema and pass your schema as the input as an escaped string. You can’t send just your schema like you tried above to the admin endpoint.