Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 35 forks source link

extendWithMutations function takes the last mutation passed always #76

Closed JuMaLeCu closed 5 years ago

JuMaLeCu commented 5 years ago

Hello there! I am trying to create multiple mutations but the function of extendWithMutations only takes the last mutation that I enter as a parameter.

This is my SchemaBuilder

const schemaBuilder = graphQlBuilder().allModels(models);

extendAllMutations(schemaBuilder);

const schema = schemaBuilder.build();

extendAllMutations is a personal function that I created for all mutations to be added to the variable schemaBuilder.

This is the extendAllMutations function:

const extendAllMutations = builder => {
  getMutations().forEach(mutation => builder.extendWithMutations(mutation));
};

getMutations is a function that reads the mutations from a folder that I have all the files that contain the different mutations that I want to implement on the server

I have tried introducing the models one by one and using twice the function spreadWithMutations on that same model and exactly the same thing happens. I think I should let you add all the mutations instead of replacing them.

const schema = graphQlBuilder()
   .model(user)
   .extendWithMutations(loginMutation)
   .extendWithMutations(signupMutation)
   .build();

I have not seen in the documentation anything about it, so I better ask around here. Thank you for your attention and forgive the inconvenience that may cause.

JuMaLeCu commented 5 years ago

Im sorry. I did not read correctly the graphql documentation and I resolve for myself this issue. I thought I had to invoke extendsWithMutations for each mutation object I had create before. Reading graphql´s doc I saw that all mutations I want is writing all of them in the same object. I thought that I had to invoke it in there object by object.

My bad, sorry, I´m already learning how to use this powerful tool named graphql 😅