I am looking to do something similar to the curl schema upload in the docs: curl -X POST localhost:8080/admin/schema --data-binary '@schema.graphql'
but Instead doing it within a Node program. I would much prefer to use something like Request or Axios as opposed to running a exec for curl within the node program. I know you can update the schema using graphql but I would prefer not to instantiate a graphql client just for this. I am currently trying using axios, which does not produce an error but does not update the schema correctly. The typeArray is created through graphql-tools schema loading and is an array of graphql schema strings and if I just write the result to a .graphql file and then curl it to dgraph it works fine.
As the injection of the Schema is a mutation you should follow that logic. The curl method is different.
Admin Schema
type GQLSchema @dgraph(type: "dgraph.graphql") {
id: ID!
"""
Input schema (GraphQL types) that was used in the latest schema update.
"""
schema: String! @dgraph(pred: "dgraph.graphql.schema")
"""
The GraphQL schema that was generated from the 'schema' field.
This is the schema that is being served by Dgraph at /graphql.
"""
generatedSchema: String!
}
Here is what is currently working for us using fetch. There would be less need to convert to/from json with axios in general, but we also had to convert the schema.toString() before pushing it. We don’t have any @key fields, but we do have other directives and this is working for us. Maybe this will help get you going.