graphql-community / koa-graphql

Create a GraphQL HTTP server with Koa.
MIT License
843 stars 61 forks source link

Input Data of a Mutation are not based on Standard JavaScript Object/ Array #89

Closed vanthome closed 7 years ago

vanthome commented 7 years ago

If I have a mutation like this:

import { mutationWithClientMutationId } from 'graphql-relay';
export default mutationWithClientMutationId({
  name: 'BulkImportOrganizations',
  inputFields: {
    listOfOrganizations: {
      type: new GraphQLList(OrganizationType),
    },
    apiKey: {
      type: GraphQLString,
    },
  },
  mutateAndGetPayload: async({ listOfOrganizations, apiKey }) => {
    const output = {
      regStatus: [],
      error: {
        code: [],
        message: []
      }
    };

I wounder why is listOfOrganizations not an array? It seems to be a pseudo array but does not implement the corresponding methods according to the Array Prototype neither it has the Array prototype. The same goes for plain Objects.

chentsulin commented 7 years ago

If I’m not mistaken, this should not be an issue relative to koa-graphql repo.

vanthome commented 7 years ago

ok but what else?

chentsulin commented 7 years ago

All of GraphQL queries are executed directly by GraphQL-js, so if you have any questions about that you should go to see the implementation there.

https://github.com/chentsulin/koa-graphql/blob/1ff01ea269d665dae5020593bb7a458611f4f35d/src/index.js#L255-L271