Don't shoot me if I'm wrong. But I guess the JSON is converted automatically on the server side. You don't really receive a single string; you'll receive a json object.
I see in my code that I'm passing the json-objects directly to a json-schema-validator for custom validation. Without a JSON.parse
. So in no way it's comming trough as a single string. It's a json object
.
mutation{
newEvent(
platform: mfd
attributes: "{\"1\":\"2\"}"
)
}
{
"platform": "mfd",
"attributes": {
"1": "2"
}
}
newEvent(
platform: mfd
attributes: {
action: "asdasd"
}
)
}
Validation error of type WrongType: argument 'attributes' with value 'ObjectValue{objectFields=[ObjectField{name='action', value=StringValue{value='asdasd'}}]}' is not a valid 'AWSJSON' @ 'newEvent'
Good afternoon guys, I am new in GraphQL and I have some questions about your handler. I would like to provide at the same endpoint different queries and mutations via body in JSON format.
{
"query" : "{readUsers {id, username}}"
}
{
"mutation" : "{createUser(username:\"Andrea\")}{id,username}"
}
The first query action works because handler manages the "query" value, but it seems from the code that is not the same for "mutation" field.
How could I achieve my goal?
All, I'm working on a project where almost all queries / mutations require
us to pass a 'project id' as the first parameter. For example:
query getUsers(projectId = "123", other parameters...) { ... }
or
query getComments(projectId = "123", other parameters...) { ... }
Rather than having the id as an explicit input parameter to every query / mutation,
is there a preferred way for the frontend to pass this information to the backend?
The approaches I've considered so far are: 1) Attach the id via HTTP headers, or
2) Attach the id as a query parameter to every GraphQL request? Ex:/graphQL?projectId=123
Field
in Fields.
Author
and a Book
Is there any good example for Subscription with Spring Boot application? I have tried the example in spring boot examples repo, but It is stacked at: "Your subscription data will appear here after server publication!"
I have found this too: https://jivimberg.io/blog/2018/10/23/reactive-graphql-subscriptions-from-kafka/ but dependencies are missing and It is Kotlin and not Java...
Hi!
I’ve two queries which don’t have parameters:
GetInventory(): Int!
and:
LogoutUser(): null
Both fail with following error:
Syntax Error: Expected Name, found )
If I add name: String
it works but they don’t need arguments. Can you please assist me solving this error?
I use import {buildSchema} from 'graphql‘;
to build the schema for express-graphql server.
const schema = buildSchema([typeDefs, operations].join('\r\n'));
Where typeDefs is a concatenated string of all types and operations contains concatenated mutations and queries.
this is the contents of operations
:
https://gist.github.com/renepardon/c600f2b207858301f4f36e5206fea395
deleteNote = async (id) => {
try {
const { deleteNote } = this.props
const response = await deleteNote({
variables: { id },
update: (proxy, { data: { deleteNote } }) => {
try {
if (!deleteNote) return
const data = proxy.readQuery({ query: myNotesQuery })
console.log(data)
data.threads.edges = data.threads.edges.filter(({ node }) => node.id !== id)
console.log(data)
proxy.writeQuery({ query: myNotesQuery, data })
} catch (e) {
console.log(e)
}
}
})
} catch (e) {
console.log(e)
}
}
data
does change but afterproxy.writeQuery
it doesn't update my component