Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Generated GraphQL schema doesn't allow arrays into update mutation #2203

Closed
mckenziecallum opened this issue Nov 9, 2020 · 5 comments · Fixed by #2205
Closed

Generated GraphQL schema doesn't allow arrays into update mutation #2203

mckenziecallum opened this issue Nov 9, 2020 · 5 comments · Fixed by #2205
Labels
bug Something isn't working triage

Comments

@mckenziecallum
Copy link

mckenziecallum commented Nov 9, 2020

  • Module: graphback-core
  • Version: 1.0.1
  • Node.js / npm versions: Node:v15.0.1 NPM:6.14.8
  • Example/snippet of the model that is causing issue

Schema

type Volunteer {
    _id: GraphbackObjectID!
    name: String!
    email: String
    preferredDays: [DaysOfWeek]
    skills:[String]
}

enum {
    MONDAY,
    TUESDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY
}

Generated Mutation

type Mutation {
    updateVolunteer(input: MutateVolunteerInput!): Volunteer
}

input MutateVolunteerInput {
  _id: GraphbackObjectID!
  name: String
  email: String
  preferredDays: DaysOfWeek
  skills: String
}

....

What I was expecting this to generate is:

Expected Mutation

type Mutation {
    updateVolunteer(input: MutateVolunteerInput!): Volunteer
}

input MutateVolunteerInput {
  _id: GraphbackObjectID!
  name: String
  email: String
  preferredDays: [DaysOfWeek]
  skills: [String]
}

....

I would expect the skills field in MutateVolunteerInput to be an array of Strings. At the moment I can create a Volunteer with an array of skills, however once I update with the above mutation all queries fail since it cannot convert a string back to an array of strings.

If you need anymore info let me know

@mckenziecallum mckenziecallum added the bug Something isn't working label Nov 9, 2020
@machi1990
Copy link
Contributor

Automatically generated comment to notify maintainers
/cc @craicoverflow, @machi1990, @wtrocki

@wtrocki
Copy link
Contributor

wtrocki commented Nov 9, 2020

Thank you for logging issue. This is due to no representation for array in graphback - array is relationship to type so if we do not have it as relation things could be tricky. Looks like simple fix.

@craicoverflow I think we had some workaround for this right?

@craicoverflow
Copy link

This is a small bug. I've put out a fix in #2205.

@mckenziecallum
Copy link
Author

mckenziecallum commented Nov 10, 2020

Ah brilliant! Have you guys got a plan to do a release of the fix to NPM anytime soon?

@craicoverflow
Copy link

We have releases 1.1.0 - please try it out 😄

https://github.com/aerogear/graphback/releases/tag/1.1.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants