graphiql

GraphQl variable using grapiql - variable is undefined

柔情痞子 提交于 2019-12-18 09:51:44
问题 I am using this endpoint: @PostMapping("graphql") public ResponseEntity<Object> getResource(@RequestBody Object query) { // String query ExecutionResult result; if (query instanceof String) { result = graphQL.execute(query.toString()); // if plain text } else{ String queryString = ((HashMap) query).get("query").toString(); Object variables = ((HashMap) query).get("variables"); ExecutionInput input = ExecutionInput.newExecutionInput() .query(queryString) .variables((Map<String, Object>)

GraphiQL Returning null Values When Fetching All Records [duplicate]

限于喜欢 提交于 2019-12-08 03:28:03
问题 This question already has an answer here : Why does a GraphQL query return null? (1 answer) Closed 6 months ago . I am trying to build a simple GraphQL schema. I have an json-server endpoint running on localhost which returns some simple json data. I can return a user when supplying an id. The query to do this in the schema looks like this: staff: { type: StaffType, args: { id: { type: GraphQLInt }}, resolve(parentValue, { id }) { return axios.get(`http://localhost:3000/staff/${id}`) .then

Django Graphene, Passing JSON or dict data as input for Mutation

人走茶凉 提交于 2019-12-08 01:37:04
问题 I have the following situation: I have a User, each user has a Inventory. I'm struggling to declare the user's inventory in the Mutation "CreateUser". Here is the following mutation for creating the user: mutation Create{ addUser(UserData:{name:"Shibunika",age:21} } I'm trying to declare the user's inventory in this mutation, I expected something like mutation Create{ addUser(UserData:{name:"Shibunika",age:21,inventory:{'item1':45,'item2':25} }s these number are the quantity of each item. How

Django Graphene, Passing JSON or dict data as input for Mutation

泪湿孤枕 提交于 2019-12-06 07:37:09
I have the following situation: I have a User, each user has a Inventory. I'm struggling to declare the user's inventory in the Mutation "CreateUser". Here is the following mutation for creating the user: mutation Create{ addUser(UserData:{name:"Shibunika",age:21} } I'm trying to declare the user's inventory in this mutation, I expected something like mutation Create{ addUser(UserData:{name:"Shibunika",age:21,inventory:{'item1':45,'item2':25} }s these number are the quantity of each item. How do I define these inputs in graphene? Would you gently show me a schema for this? You can create a