Skip to content

Add coordinate field to schema element definitions #3808

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

Open
wants to merge 1 commit into
base: schema-coordinates
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,23 @@ export type { GraphQLArgs } from './graphql.js';
export { graphql, graphqlSync } from './graphql.js';

// Create and operate on GraphQL type definitions and schema.
export type {
GraphQLField,
GraphQLArgument,
GraphQLEnumValue,
GraphQLInputField,
} from './type/index.js';
export {
resolveObjMapThunk,
resolveReadonlyArrayThunk,
// Definitions
GraphQLSchema,
GraphQLDirective,
GraphQLSchemaElement,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering here from #3044 (comment). I missed that PR during the recent coordinates dicussion. Do we need GraphQLSchemaElement?

I'm fine if there's no "bidirectionality" between a coordinate and a schema element. We could even have GraphQLSchemaElement without the coordinate property and that would probably be fine for me too. In other words, I'm ok with coordinates being "1-way".

Did we have any more context about this? Are there use cases out there that would benefit from GraphQLField having a coordinate property for an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ask @leebyron for more context, I think the original idea was to use the coordinate concept as an internal convenience to standardize our error messages. In #4288 we basically took the concept with their standardized error messages without the coordinate field itself, so that's why this rebased PR doesn't have a large error message diff and #3145 does.

GraphQLScalarType,
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLEnumType,
GraphQLInputObjectType,
GraphQLField,
GraphQLArgument,
GraphQLEnumValue,
GraphQLInputField,
GraphQLList,
GraphQLNonNull,
// Standard GraphQL Scalars
Expand Down
11 changes: 11 additions & 0 deletions src/type/__tests__/definition-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ describe('Type System: Objects', () => {
}),
});
expect(objType.getFields().f).to.deep.include({
coordinate: 'SomeObject.f',
parentType: objType,
name: 'f',
description: undefined,
Expand Down Expand Up @@ -358,6 +359,7 @@ describe('Type System: Objects', () => {
const f = objType.getFields().f;

expect(f).to.deep.include({
coordinate: 'SomeObject.f',
parentType: objType,
name: 'f',
description: undefined,
Expand All @@ -372,6 +374,7 @@ describe('Type System: Objects', () => {
expect(f.args).to.have.lengthOf(1);

expect(f.args[0]).to.deep.include({
coordinate: 'SomeObject.f(arg:)',
parent: f,
name: 'arg',
description: undefined,
Expand Down Expand Up @@ -736,6 +739,8 @@ describe('Type System: Enums', () => {
expect(values).to.have.lengthOf(3);

expect(values[0]).to.deep.include({
coordinate: 'EnumWithNullishValue.NULL',
parentEnum: EnumTypeWithNullishValue,
name: 'NULL',
description: undefined,
value: null,
Expand All @@ -745,6 +750,8 @@ describe('Type System: Enums', () => {
});

expect(values[1]).to.deep.include({
coordinate: 'EnumWithNullishValue.NAN',
parentEnum: EnumTypeWithNullishValue,
name: 'NAN',
description: undefined,
value: NaN,
Expand All @@ -754,6 +761,8 @@ describe('Type System: Enums', () => {
});

expect(values[2]).to.deep.include({
coordinate: 'EnumWithNullishValue.NO_CUSTOM_VALUE',
parentEnum: EnumTypeWithNullishValue,
name: 'NO_CUSTOM_VALUE',
description: undefined,
value: 'NO_CUSTOM_VALUE',
Expand Down Expand Up @@ -856,6 +865,7 @@ describe('Type System: Input Objects', () => {
},
});
expect(inputObjType.getFields().f).to.deep.include({
coordinate: 'SomeInputObject.f',
parentType: inputObjType,
name: 'f',
description: undefined,
Expand All @@ -876,6 +886,7 @@ describe('Type System: Input Objects', () => {
}),
});
expect(inputObjType.getFields().f).to.deep.include({
coordinate: 'SomeInputObject.f',
parentType: inputObjType,
name: 'f',
description: undefined,
Expand Down
2 changes: 2 additions & 0 deletions src/type/__tests__/directive-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Type System: Directive', () => {
expect(directive.args).to.have.lengthOf(2);

expect(directive.args[0]).to.deep.include({
coordinate: '@Foo(foo:)',
parent: directive,
name: 'foo',
description: undefined,
Expand All @@ -52,6 +53,7 @@ describe('Type System: Directive', () => {
});

expect(directive.args[1]).to.deep.include({
coordinate: '@Foo(bar:)',
parent: directive,
name: 'bar',
description: undefined,
Expand Down
2 changes: 2 additions & 0 deletions src/type/__tests__/enumType-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ describe('Type System: Enum Values', () => {

expect(values[0]).to.deep.include({
parentEnum: ComplexEnum,
coordinate: 'Complex.ONE',
name: 'ONE',
description: undefined,
value: Complex1,
Expand All @@ -408,6 +409,7 @@ describe('Type System: Enum Values', () => {

expect(values[1]).to.deep.include({
parentEnum: ComplexEnum,
coordinate: 'Complex.TWO',
name: 'TWO',
description: undefined,
value: Complex2,
Expand Down
Loading
Loading