misnomer42
misnomer42

Reputation: 589

GraphQL mutation takes an array as an input parameter and returns a json String

I'm trying to implement mutation query with an array as a parameter and String as a return type.

Here is my schema file:

input OrganizationInput {
    orgId: String!
    orgName: String!
}
type Mutations {
     importOrganizations(input: [OrganizationInput]): String
}

Here is my mutation:

mutation importOrganizations($orgs: [OrganizationInput]) {
    importOrganizations(
        input: {
            orgId: id,
            orgName: name
        }
    )
}

This code doesn't work, but I don't know how to do it properly.

Maybe someone more experienced in GraphQL could help me?

Upvotes: 0

Views: 131

Answers (1)

flzzz
flzzz

Reputation: 543

Do you have any errors that can help?

Anyways your mutation need to return fields, e.g.:

mutation importOrganizations($orgs: [OrganizationInput]) {
    importOrganizations(
        input: {
            orgId: id,
            orgName: name
            })
        {
            id
            name
        }
}

Upvotes: 1

Related Questions