0

I have a MongoDB mongoose schema like this:

const playerSchema = Schema({                    
    conditions: { type : Object },                 
    date: String    
}) 

With a collection like this:

{
 _id: 5cee935cb56d5f794b452d78,
 conditions:
 { 
    condition_a: [5.9, 6.0],
    condition_b: [6.1, 4.9],
    condition_c: [4.9, 4.0]
 },     
 date: 'Wed May 29 2019 16:45:00 GMT+0200 (GMT+02:00)',
},
{
 _id: 5cee935cb56d5f794b452d70,
 conditions:
 { 
    condition_a: [5.8, 6.1],        
    condition_c: [4.3, 3.0]
 },     
 date: 'Wed May 29 2019 16:47:00 GMT+0200 (GMT+02:00)',
},
[...]

How I can make GraphQL Schema for this? I've tried something like this

buildSchema(`
 type Player {
    _id: ID!    
    condition: Object         
    date: String         
 }
`)

Also tried: [[String]] , {} , {String} ... with no lucky

Make a collection with conditions and relations to Player is not a option.

kurtko
  • 1,978
  • 4
  • 30
  • 47

1 Answers1

0

Solved with:

type Condition {
    condition_a: [String],
    condition_b: [String],
    condition_c: [String],    
}

type Player {
    _id: ID!    
    condition: Condition         
    date: String         
 }
kurtko
  • 1,978
  • 4
  • 30
  • 47