graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Option to disable OGM type generations

Open eriklueth opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. In my GraphQL Schema, I have some types which are only used to return data via the @customResolver directive. Like the following:

export const typeDefs = gql`
  type OnboardingURLResponse
    @exclude {
    onboardingURL: String
  }

  type Query {
    retrieveOnboardingURL(
      accountID: ID!
    ): OnboardingURLResponse!
  }`;

export const queryResolvers = {
  retrieveOnboardingURL,
};

export async function retrieveStripeOnboardingURL(
  _root: any,
  args: RetrieveAccountArgs,
  context: Context
) {
return {
    onboardingURL: "https://test.com",
  };
}

This is generating OGM Models and types like this, which are unnecessary: image Here the errors in the generated models are coming because the name of the type has more than one consecutive uppercase letter, here it is coming from the "URL" part. I opened an issue for it under #3539

Here the OnboardingURLResponse should never have any Neo4J GraphQL OGM things generated for it similar to how the @exclude directive is currently disabling the generation for the Schema.

My generated OGM Types file is over 150.000 Lines long and could be massively reduced by it.

Describe the solution you'd like

Since you switched away from @exclude here is a possible solution for the new way of doing things via the @query, @mutation, and @subscription directives.:

  type RetrieveOnboardingURLResponse
    @query(read: false, aggregate: false, ogmRead: false, ogmAggregate: false)
    @mutation(operations: [], ogmOperations: [])
    @subscription(operations: [], ogmOperations: []) {
    onboardingURL: String
  }

or actually, the better way would be to make a directive like "@externalType" to just disable any Neo4J GraphQL Type and Schema generation for the type.

eriklueth avatar Jun 22 '23 13:06 eriklueth