question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support hooks to add custom documentation to objects, fields, arguments and enum values

See original GitHub issue

We came up with a documentation technique that works well for us (syncing both development teams and our product documentation team). We’re trying to resolve the relevant Markdown documentation for each object, field, argument and enum value.

SchemaGeneratorHooks is an awesome general purpose vehicle for intercepting schema generation. I think it can be very helpful in this case, but it would have to be extended to include hook methods that would allow me to augment builder objects just before calling build(). That way I can call the builders’ description method and add my own documentation. Specifically I’m asking for the inclusion of the following hooks:

fun willGenerateGraphQLObject(objectName: String, builder: graphql.schema.GraphQLObjectType.Builder): graphql.schema.GraphQLObjectType.Builder = builder

fun willGenerateGraphQLField(objectName: String, fieldName: String, builder: graphql.schema.GraphQLFieldDefinition.Builder): graphql.schema.GraphQLFieldDefinition.Builder = builder

fun willGenerateGraphQLEnumType(enumName: String, builder: graphql.schema.GraphQLEnumType.Builder): graphql.schema.GraphQLEnumType.Builder = builder

fun willGenerateGraphQLEnumValue(enumName: String, enumValue: String, builder: graphql.schema.GraphQLEnumValueDefinition.Builder): graphql.schema.GraphQLEnumValueDefinition.Builder = builder

fun willGenerateGraphQLArgument(objectName: String, fieldName: String, argumentName: String, builder: graphql.schema.GraphQLArgument.Builder): graphql.schema.GraphQLArgument.Builder = builder

I added the names of the objects/fields/arguments/enums to the hooks’ contexts since it’s difficult to extract that information from the builders directly.

What do you think?

Thanks a lot for a fantastic library!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
smyrickcommented, Jun 6, 2019

@liqweed You can access the name of the generatedType since at this point in the hook, it is fully generated. You can also look at the info on the KType but that is not always the most accurate if you are using this like @GraphQLName to override the type name. You don’t have to traverse any builder, but if you want to edit the type, you can pass it into a new builder and edit the fields that way to produce a new generated GraphQLType


@rharriso This hook can be used at this point to add any more info to the type, not just documentation. We already have a way to do custom directives, documented here: https://github.com/ExpediaDotCom/graphql-kotlin/wiki/Schema-Directives

The comment you are referring to is a way to expose a config method or setting to provide a list of pre-configured directives instead of using the onRewireGraphQLType. There are slightly different issues.

0reactions
smyrickcommented, Jul 26, 2019

@liqweed These seems like a valid error, I have created a new issue which is open for anyone to work on https://github.com/ExpediaDotCom/graphql-kotlin/issues/281

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create an enum option – Asana
Custom fields values are set for each individual task. ... A user object represents an account in Asana that can be given access...
Read more >
How can I guarantee that my enums definition doesn't change ...
So you should be able to create a custom object, then call Enum() on it. The values assigned start at 0 and increment...
Read more >
Enums - GitHub Docs
Enums represent possible sets of values for a field. For example, the Issue object has a field called state . The state is...
Read more >
CRM API | Properties - HubSpot Developers
The CRM properties endpoints allow you to manage custom properties as well as view default property details for any object.
Read more >
enum — Support for enumerations — Python 3.11.1 ...
An enumeration with the values CONTINUOUS , NAMED_FLAGS , and UNIQUE , for use with verify() to ensure various constraints are met by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found