@custom mutation: underscores within POST body

According to https://graphql.dgraph.io/doc/custom/directive this example works:

type Mutation {
    newMovie(title: String!, desc: String, dir: ID, imdb: ID): Movie @custom(http: {
            url: "http://myapi.com/movies",
            method: "POST",
            body: "{ title: $title, imdbID: $imdb, storyLine: $desc, director: { id: $dir }}",
    })
}

But does not work with underscores:

type Mutation {
    newMovie(title: String!, desc: String, dir: ID, imdb: ID): Movie @custom(http: {
            url: "http://myapi.com/movies",
            method: "POST",
            body: "{ my_title: $title, imdbID: $imdb, storyLine: $desc, director: { id: $dir }}",
    })
}

Errors with: Type Mutation; Field newMovie; body template inside @custom directive could not be parsed.
Is it an error/omission? It would help if we could use underscores there.

1 Like

Thanks, This is a limitation currently. At present, only [a-zA-Z] is supported as the character set for keys in body. We should expand it to accept general things like underscores, hyphens or basically any character that one may use in json keys.

1 Like

Update: We will ship it out with scalar support in body. That will solve both the problems at once.

1 Like

Hey @miko,
This has been added in master with this PR.
Note that now the character set for keys in body is /[_A-Za-z][_0-9A-Za-z]*/ which is same as the character set for names in GraphQL spec.

Closing this topic.

Thanks

1 Like