Gqlgen: Make gqlgen resolver config more flexible

Created on 9 May 2020  路  4Comments  路  Source: 99designs/gqlgen

Hi!

I think current config options (as of 0.11.3) lacks flexibility in way existing code is managed.
Here is my problem. My project contains many mutations and resolvers. So whenever I add something in schema I implement it in separate file to avoid bloating resolvers.go.

With the new way (I mean layout: follow-schema) I can now cut single .graphql into few smaller files and get a bunch of clean and small .go files automatically. And I really like it!
But there still a Mutation type that remains indivisible. Imagine if you have

type Mutation {
  mutationA()
  mutationB()
  few dozen mutations()
  ....
}

At least one of .go files will contain code of all these mutations.
And if I spread them into separate files they all will be moved back to original file on next run of gqlgen.

So I wonder if it is possible to add a new option in addition to layout: follow-schema that would allow to not move existing code into per-schema-file but keep it where it is.

Or maybe an option to generate a .go file per mutation?

stale

Most helpful comment

You can extend the mutation type in each .graphql file to organize better your schema. However, I've never tried using it with the new layout of generated resolvers to know which file the generated mutation function will be live.

example:

// file a.graphql
type Mutation {
  doSomething: Any
}
// file b.graphql
extend type Mutation {
  doOtherThing: Any
}

All 4 comments

You can extend the mutation type in each .graphql file to organize better your schema. However, I've never tried using it with the new layout of generated resolvers to know which file the generated mutation function will be live.

example:

// file a.graphql
type Mutation {
  doSomething: Any
}
// file b.graphql
extend type Mutation {
  doOtherThing: Any
}

Good point @landrade !
I didn't think of it. Will try and post my results here :+1:

Yep, works just fine! :+1:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bieber picture bieber  路  4Comments

andrewmunro picture andrewmunro  路  4Comments

itsbalamurali picture itsbalamurali  路  4Comments

cemremengu picture cemremengu  路  3Comments

imiskolee picture imiskolee  路  3Comments