With the above function, you could now easily do stuff like the following:
fields := graphql.Fields{
"hello": &graphql.Field{
Type: graphql.String,
Resolve: AsyncResolve(func(p graphql.ResolveParams) (interface{}, error) {
fmt.Println("hello")
time.Sleep(5 * time.Second)
fmt.Println("hello done")
return "hello", nil
}),
},
"world": &graphql.Field{
Type: graphql.String,
Resolve: AsyncResolve(func(p graphql.ResolveParams) (interface{}, error) {
fmt.Println("world")
time.Sleep(3 * time.Second)
fmt.Println("world done")
return "world", nil
}),
},
}
and voila, you've got resolvers that run concurrently :)
fields must be an object with field names as keys or a function which return such an object
var getResultat =&graphql.Field{
Type : ????????????
Args : graphql.FieldConfigArgument{
"type": &graphql.ArgumentConfig{
Type : strings,
}
"code": &graphql.ArgumentConfig{
Type : strings,
}
}
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
filter := bson.M{}
if T := p.Args["type"]; T != nil {
filter["type"] = T.(string)
return (&models.A{}).listA(filter)
}
if B := p.Args["isHappy"]; B != nil {
filter["isbn"] = I.(string)
}
return (&models.Book{}).listB(filter)
},
}
dddw
anyone know a good manual to deploy graphql with nginx ssl termination ?Hi All,
How can I write Graphql Types for an Array of Objects inside Object inside Object inside root Object?
Ex: {
trigger_info : {
trigger_data: {
[
{
trigger_id : "001",
trigger_date : "01/02/20",
trigger_user : "John",
trigger_description : "xxxxxxxx"
},
{
trigger_id : "002",
trigger_date : "01/03/20",
trigger_user : "Paul",
trigger_description : "xxxxxxxx"
},
{
trigger_id : "003",
trigger_date : "01/05/20",
trigger_user : "Finch",
trigger_description : "xxxxxxxx"
}
]
}
}
}
Can Anyone please let me know the model for this above example. If you can, It would be more helpful for me. Thanks a lot in advance.
@silentnull @patcito@gmail.com @mail@matthiasloibl.com
Hey all, looking for some assistance with nested object OR subdocuments, I'm not sure which use case is correct. I've got Graphql in front of MongoDB. The object in my schema is not flat, it has 1 property that is an object. I need to be able to select object based on values in the properties of this child object.
Does anyone know of a good example of this that they could link me to?
Mongo data:
{
car: {
color: "red",
engine: { hp: 10 }
}
}
Graph Schema I tried, seams invalid.
type Car {
color: String
engine: {
hp: Int
}
}
Other schema I tried, compiles but I can't figure out how to filter on the child object:
type Engine {
hp: Int
}
type Car {
color: String
engine: Engine
}
trajanus
It looks like just what I need but wanted to solicit any impressions or tips from those who have already used it.
Hi
Just published graphql api generator for mongodb (that can be extended with your own queries/mutations). https://github.com/coolemur/graphql-api-generator . It takes simple json schema object definition (custom) and generates API CRUD (with search, find, sort, take, skip)
Check it out
It's just a beginning, but I will try to add more features later
Hi,
Im new to graphQL and Im inserting an entry something like this-
def insertFibEntry(self, prefix, name): # returns FIB entry ID
fib = self.graphQLClient.fetch("""
mutation insertFibEntry($name: Name!, $nexthops: [ID!]!) {
insertFibEntry(name: $name, nexthops: $nexthops) {
id
}
}
""", {
'name': "/"+prefix ,
'nexthops': [self.faces[name]['data']['createFace']['id']
})
info('***fib result %s\n' % fib)
info('***prefix is %s'% "'/"+prefix+"'"+ '\n')
Now I am looking to delete the entry. How would I make a similar function to delete the entry?