Skip to content

Commit

Permalink
Rename graphql export to g (#9460)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Feb 5, 2025
1 parent e725451 commit c6ce0a7
Show file tree
Hide file tree
Showing 72 changed files with 1,843 additions and 1,795 deletions.
7 changes: 7 additions & 0 deletions .changeset/lemon-oranges-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@keystone-6/fields-document": major
"@keystone-6/cloudinary": major
"@keystone-6/auth": major
---

Prefer `g` instead of `graphql` when importing from `@keystone-6/core`
5 changes: 5 additions & 0 deletions .changeset/small-kiwis-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-6/core": minor
---

Rename `graphql` export to `g` - `graphql` is still exported but is deprecated and may be removed in a future release
12 changes: 6 additions & 6 deletions examples/custom-field/1-text-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fieldType,
orderDirectionEnum,
} from '@keystone-6/core/types'
import { graphql } from '@keystone-6/core'
import { g } from '@keystone-6/core'

type TextFieldConfig<ListTypeInfo extends BaseListTypeInfo> = CommonFieldConfig<ListTypeInfo> & {
isIndexed?: boolean | 'unique'
Expand All @@ -25,16 +25,16 @@ export function text<ListTypeInfo extends BaseListTypeInfo> ({
...config,
input: {
create: {
arg: graphql.arg({ type: graphql.String }),
arg: g.arg({ type: g.String }),
resolve (value, context) {
return value
},
},
update: { arg: graphql.arg({ type: graphql.String }) },
orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) },
update: { arg: g.arg({ type: g.String }) },
orderBy: { arg: g.arg({ type: orderDirectionEnum }) },
},
output: graphql.field({
type: graphql.String,
output: g.field({
type: g.String,
resolve ({ value, item }, args, context, info) {
return value
},
Expand Down
12 changes: 6 additions & 6 deletions examples/custom-field/2-stars-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fieldType,
orderDirectionEnum,
} from '@keystone-6/core/types'
import { graphql } from '@keystone-6/core'
import { g } from '@keystone-6/core'

// this field is based on the integer field
// but with validation to ensure the value is within an expected range
Expand Down Expand Up @@ -47,7 +47,7 @@ export function stars <ListTypeInfo extends BaseListTypeInfo> ({
// all of these inputs are optional if they don't make sense for a particular field type
input: {
create: {
arg: graphql.arg({ type: graphql.Int }),
arg: g.arg({ type: g.Int }),
// this field type doesn't need to do anything special
// but field types can specify resolvers for inputs like they can for their output GraphQL field
// this function can be omitted, it is here purely to show how you could change it
Expand All @@ -67,11 +67,11 @@ export function stars <ListTypeInfo extends BaseListTypeInfo> ({
return val
},
},
update: { arg: graphql.arg({ type: graphql.Int }) },
orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) },
update: { arg: g.arg({ type: g.Int }) },
orderBy: { arg: g.arg({ type: orderDirectionEnum }) },
},
output: graphql.field({
type: graphql.Int,
output: g.field({
type: g.Int,
// like the input resolvers, providing the resolver is unnecessary if you're just returning the value
// it is shown here to show what you could do
resolve ({ value, item }, args, context, info) {
Expand Down
26 changes: 13 additions & 13 deletions examples/custom-field/3-pair-field-json/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type FieldTypeFunc,
fieldType,
} from '@keystone-6/core/types'
import { graphql } from '@keystone-6/core'
import { g } from '@keystone-6/core'

type PairFieldConfig<ListTypeInfo extends BaseListTypeInfo> = CommonFieldConfig<ListTypeInfo>

Expand All @@ -14,26 +14,26 @@ type PairInput = {
}
type PairOutput = PairInput

const PairInput = graphql.inputObject({
const PairInput = g.inputObject({
name: 'PairJsonInput',
fields: {
left: graphql.arg({ type: graphql.String }),
right: graphql.arg({ type: graphql.String }),
left: g.arg({ type: g.String }),
right: g.arg({ type: g.String }),
},
})

const PairOutput = graphql.object<PairOutput>()({
const PairOutput = g.object<PairOutput>()({
name: 'PairJsonOutput',
fields: {
left: graphql.field({ type: graphql.String }),
right: graphql.field({ type: graphql.String }),
left: g.field({ type: g.String }),
right: g.field({ type: g.String }),
},
})

const PairFilter = graphql.inputObject({
const PairFilter = g.inputObject({
name: 'PairJsonFilter',
fields: {
equals: graphql.arg({
equals: g.arg({
type: PairInput,
}),
},
Expand Down Expand Up @@ -71,25 +71,25 @@ export function pair<ListTypeInfo extends BaseListTypeInfo> (
...config,
input: {
where: {
arg: graphql.arg({ type: PairFilter }),
arg: g.arg({ type: PairFilter }),
resolve (value, context) {
return resolveWhere(value)
},
},
create: {
arg: graphql.arg({ type: PairInput }),
arg: g.arg({ type: PairInput }),
resolve (value, context) {
return resolveInput(value)
},
},
update: {
arg: graphql.arg({ type: PairInput }),
arg: g.arg({ type: PairInput }),
resolve (value, context) {
return resolveInput(value)
},
},
},
output: graphql.field({
output: g.field({
type: PairOutput,
resolve ({ value, item }, args, context, info) {
return resolveOutput(value)
Expand Down
26 changes: 13 additions & 13 deletions examples/custom-field/3-pair-field-nested/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type FieldTypeFunc,
fieldType,
} from '@keystone-6/core/types'
import { graphql } from '@keystone-6/core'
import { g } from '@keystone-6/core'

type PairFieldConfig<ListTypeInfo extends BaseListTypeInfo> = CommonFieldConfig<ListTypeInfo>

Expand All @@ -14,26 +14,26 @@ type PairInput = {
}
type PairOutput = PairInput

const PairInput = graphql.inputObject({
const PairInput = g.inputObject({
name: 'PairNestedInput',
fields: {
left: graphql.arg({ type: graphql.String }),
right: graphql.arg({ type: graphql.String }),
left: g.arg({ type: g.String }),
right: g.arg({ type: g.String }),
},
})

const PairOutput = graphql.object<PairOutput>()({
const PairOutput = g.object<PairOutput>()({
name: 'PairNestedOutput',
fields: {
left: graphql.field({ type: graphql.String }),
right: graphql.field({ type: graphql.String }),
left: g.field({ type: g.String }),
right: g.field({ type: g.String }),
},
})

const PairFilter = graphql.inputObject({
const PairFilter = g.inputObject({
name: 'PairNestedFilter',
fields: {
equals: graphql.arg({
equals: g.arg({
type: PairInput,
}),
},
Expand Down Expand Up @@ -81,25 +81,25 @@ export function pair<ListTypeInfo extends BaseListTypeInfo> (
...config,
input: {
where: {
arg: graphql.arg({ type: PairFilter }),
arg: g.arg({ type: PairFilter }),
resolve (value, context) {
return resolveWhere(value)
},
},
create: {
arg: graphql.arg({ type: PairInput }),
arg: g.arg({ type: PairInput }),
resolve (value, context) {
return resolveInput(value)
},
},
update: {
arg: graphql.arg({ type: PairInput }),
arg: g.arg({ type: PairInput }),
resolve (value, context) {
return resolveInput(value)
},
},
},
output: graphql.field({
output: g.field({
type: PairOutput,
resolve ({ value, item }, args, context, info) {
return resolveOutput(value)
Expand Down
18 changes: 9 additions & 9 deletions examples/custom-field/3-pair-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import {
type FieldTypeFunc,
fieldType,
} from '@keystone-6/core/types'
import { graphql } from '@keystone-6/core'
import { g } from '@keystone-6/core'

type PairFieldConfig<ListTypeInfo extends BaseListTypeInfo> = CommonFieldConfig<ListTypeInfo>

type PairInput = string
type PairOutput = string

const PairInput = graphql.String
const PairOutput = graphql.String
const PairInput = g.String
const PairOutput = g.String

const PairFilter = graphql.inputObject({
const PairFilter = g.inputObject({
name: 'PairFilter',
fields: {
equals: graphql.arg({ type: graphql.String }),
equals: g.arg({ type: g.String }),
},
})

Expand Down Expand Up @@ -68,25 +68,25 @@ export function pair<ListTypeInfo extends BaseListTypeInfo> (
...config,
input: {
where: {
arg: graphql.arg({ type: PairFilter }),
arg: g.arg({ type: PairFilter }),
resolve (value, context) {
return resolveWhere(value)
},
},
create: {
arg: graphql.arg({ type: PairInput }),
arg: g.arg({ type: PairInput }),
resolve (value, context) {
return resolveInput(value)
},
},
update: {
arg: graphql.arg({ type: PairInput }),
arg: g.arg({ type: PairInput }),
resolve (value, context) {
return resolveInput(value)
},
},
},
output: graphql.field({
output: g.field({
type: PairOutput,
resolve ({ value, item }, args, context, info) {
return resolveOutput(value)
Expand Down
12 changes: 6 additions & 6 deletions examples/custom-field/4-conditional-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fieldType,
orderDirectionEnum,
} from '@keystone-6/core/types'
import { graphql } from '@keystone-6/core'
import { g } from '@keystone-6/core'

type TextFieldConfig<ListTypeInfo extends BaseListTypeInfo> = CommonFieldConfig<ListTypeInfo> & {
isIndexed?: boolean | 'unique'
Expand All @@ -30,16 +30,16 @@ export function feedback<ListTypeInfo extends BaseListTypeInfo> ({
...config,
input: {
create: {
arg: graphql.arg({ type: graphql.String }),
arg: g.arg({ type: g.String }),
resolve (value, context) {
return value
},
},
update: { arg: graphql.arg({ type: graphql.String }) },
orderBy: { arg: graphql.arg({ type: orderDirectionEnum }) },
update: { arg: g.arg({ type: g.String }) },
orderBy: { arg: g.arg({ type: orderDirectionEnum }) },
},
output: graphql.field({
type: graphql.String,
output: g.field({
type: g.String,
resolve ({ value, item }, args, context, info) {
return value
},
Expand Down
Loading

0 comments on commit c6ce0a7

Please sign in to comment.