Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: cover isTypeOf and extension with jsdoc #720

Merged
merged 2 commits into from Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 41 additions & 6 deletions src/definitions/definitionBlocks.ts
Expand Up @@ -16,12 +16,35 @@ export interface CommonFieldConfig {
}

export type CommonOutputFieldConfig<TypeName extends string, FieldName extends string> = CommonFieldConfig & {
/** Arguments for the field */
/** Arguments for this field. */
args?: ArgsRecord
/**
* Custom extensions, as supported in graphql-js
* Data that will be added to the field-level [extensions field on the graphql-js type def
* instances](https://github.com/graphql/graphql-js/issues/1527) resulting from makeSchema. Useful for some
* graphql-js based tools like [join-monster](https://github.com/join-monster/join-monster) which rely on
* looking for special data here.
*
* @see https://github.com/graphql/graphql-js/issues/1527
* @example
* // taken from: https://github.com/graphql-nexus/schema/issues/683#issuecomment-735711640
*
* const User = objectType({
* name: 'User',
* extensions: {
* joinMonster: {
* sqlTable: 'USERS',
* uniqueKey: 'USER_ID',
* },
* },
* definition(t) {
* t.id('id', {
* extensions: {
* joinMonster: {
* sqlColumn: 'USER_ID',
* },
* },
* })
* },
* })
*/
extensions?: GraphQLFieldConfig<any, any>['extensions']
} & NexusGenPluginFieldConfig<TypeName, FieldName>
Expand All @@ -30,9 +53,9 @@ export type CommonInputFieldConfig<TypeName extends string, FieldName extends st
/** The default value for the field, if any */
default?: GetGen3<'inputTypes', TypeName, FieldName>
/**
* Custom extensions, as supported in graphql-js
*
* @see https://github.com/graphql/graphql-js/issues/1527
* Data that will be added to the field-level [extensions field on the graphql-js type def
* instances](https://github.com/graphql/graphql-js/issues/1527) resulting from makeSchema. Useful for some
* graphql-js based tools which rely on looking for special data here.
*/
extensions?: GraphQLInputFieldConfig['extensions']
} & NexusGenPluginFieldConfig<TypeName, FieldName>
Expand Down Expand Up @@ -65,6 +88,18 @@ export interface OutputScalarConfig<TypeName extends string, FieldName extends s
* ...then the default resolver will be available, whose behaviour is to simply return that field from the
* received source type.
*
* @example
* export const Query = queryType({
* definition(t) {
* t.list.field('posts', {
* type: 'Post',
* resolve(_, __, ctx) {
* return ctx.db.post.findMany({ where: { published: true } })
* },
* })
* },
* })
*
* @param source The [source data](https://nxs.li/guides/source-types) for the GraphQL object that this
* field belongs to, unless this is a root
* field (any field on a [root
Expand Down
28 changes: 26 additions & 2 deletions src/definitions/objectType.ts
Expand Up @@ -129,10 +129,34 @@ export type NexusObjectTypeConfig<TypeName extends string> = {
* }
*/
rootTyping?: RootTypingDef

/**
* Custom extensions, as supported in graphql-js
* Data that will be added to the field-level [extensions field on the graphql-js type def
* instances](https://github.com/graphql/graphql-js/issues/1527) resulting from makeSchema. Useful for some
* graphql-js based tools like [join-monster](https://github.com/join-monster/join-monster) which rely on
* looking for special data here.
*
* @example
* // taken from: https://github.com/graphql-nexus/schema/issues/683#issuecomment-735711640
*
* @see https://github.com/graphql/graphql-js/issues/1527
* const User = objectType({
* name: 'User',
* extensions: {
* joinMonster: {
* sqlTable: 'USERS',
* uniqueKey: 'USER_ID',
* },
* },
* definition(t) {
* t.id('id', {
* extensions: {
* joinMonster: {
* sqlColumn: 'USER_ID',
* },
* },
* })
* },
* })
*/
extensions?: GraphQLObjectType['extensions']
/**
Expand Down