2 years ago

#56317

test-img

Kholid Saifulloh

Array of String Data Type In GraphQL

I'm just learning GraphQL, but I'm confused with GraphQL schema. I have a GraphQL schema which has a string array data type

My GraphQL Schema like this:

type GetRecommender {
    resourceId: Int!
    title: String
    description: String
    content: [Content]
    tags: [Tags]
    suggestTitle: [SuggestTitle]
    input: [Input]
}

type SuggestTitle {
    input: [Input]
}

type Input {
    hello: String
}

type Content {
    hello: String
}

type Tags {
    hello: String
}

But the expected result like this:

[
  {
    resourceType: 10,
    resourceId: 102698,
    title: 'Course 1 December',
    description: 'Test',
    content: [ 'Fresh' ],
    tags: [ '2D Test Items', 'Mobile Apps' ],
    suggestTitle: { input: [Array] }
  },
  {
    resourceType: 10,
    resourceId: 102536,
    title: 'Course 3 December',
    description: 'Test',
    content: [ 'Fresh' ],
    tags: [ '2D Test Items', 'Mobile Apps' ],
    suggestTitle: { input: [Array] }
  },
]

How to write a right schema to show content, tags and suggestTitle ?

graphql

graphql-js

express-graphql

typegraphql

0 Answers

Your Answer

Accepted video resources