neo4j / graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
https://neo4j.com/docs/graphql-manual/current/
Apache License 2.0
510 stars 150 forks source link

Option to disable OGM type generations #3540

Closed eriklueth closed 18 hours ago

eriklueth commented 1 year ago

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.

jbhurruth commented 2 months ago

Does anyone know how to do this? I have a top level Query resolver which is generating broken schemas when it has nothing to do with neo4j and the @query, @mutation, and @subscription directives don't help

darrellwarde commented 18 hours ago

We've moved the OGM to LTS status and will not implement optimizations such as these.