Skip to content

SDL Spec changes #1117

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

Merged
merged 1 commit into from
Dec 6, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions src/language/__tests__/schema-kitchen-sink.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ type AnnotatedObject @onObject(arg: "value") {
annotatedField(arg: Type = "default" @onArg): Type @onField
}

type UndefinedType

extend type Foo {
seven(argument: [String]): Type
}

extend type Foo @onType

interface Bar {
one: Type
four(argument: String = "string"): String
Expand All @@ -35,16 +43,32 @@ interface AnnotatedInterface @onInterface {
annotatedField(arg: Type @onArg): Type @onField
}

interface UndefinedInterface

extend interface Bar {
two(argument: InputType!): Type
}

extend interface Bar @onInterface

union Feed = Story | Article | Advert

union AnnotatedUnion @onUnion = A | B

union AnnotatedUnionTwo @onUnion = | A | B

union UndefinedUnion

extend union Feed = Photo | Video

extend union Feed @onUnion

scalar CustomScalar

scalar AnnotatedScalar @onScalar

extend scalar CustomScalar @onScalar

enum Site {
DESKTOP
MOBILE
Expand All @@ -55,20 +79,30 @@ enum AnnotatedEnum @onEnum {
OTHER_VALUE
}

enum UndefinedEnum

extend enum Site {
VR
}

extend enum Site @onEnum

input InputType {
key: String!
answer: Int = 42
}

input AnnotatedInput @onInputObjectType {
input AnnotatedInput @onInputObject {
annotatedField: Type @onField
}

extend type Foo {
seven(argument: [String]): Type
input UndefinedInput

extend input InputType {
other: Float = 1.23e4
}

extend type Foo @onType
extend input InputType @onInputObject

directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

Expand Down
42 changes: 38 additions & 4 deletions src/language/__tests__/schema-printer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ type AnnotatedObject @onObject(arg: "value") {
annotatedField(arg: Type = "default" @onArg): Type @onField
}

type UndefinedType

extend type Foo {
seven(argument: [String]): Type
}

extend type Foo @onType

interface Bar {
one: Type
four(argument: String = "string"): String
Expand All @@ -79,16 +87,32 @@ interface AnnotatedInterface @onInterface {
annotatedField(arg: Type @onArg): Type @onField
}

interface UndefinedInterface

extend interface Bar {
two(argument: InputType!): Type
}

extend interface Bar @onInterface

union Feed = Story | Article | Advert

union AnnotatedUnion @onUnion = A | B

union AnnotatedUnionTwo @onUnion = A | B

union UndefinedUnion

extend union Feed = Photo | Video

extend union Feed @onUnion

scalar CustomScalar

scalar AnnotatedScalar @onScalar

extend scalar CustomScalar @onScalar

enum Site {
DESKTOP
MOBILE
Expand All @@ -99,20 +123,30 @@ enum AnnotatedEnum @onEnum {
OTHER_VALUE
}

enum UndefinedEnum

extend enum Site {
VR
}

extend enum Site @onEnum

input InputType {
key: String!
answer: Int = 42
}

input AnnotatedInput @onInputObjectType {
input AnnotatedInput @onInputObject {
annotatedField: Type @onField
}

extend type Foo {
seven(argument: [String]): Type
input UndefinedInput

extend input InputType {
other: Float = 1.23e4
}

extend type Foo @onType
extend input InputType @onInputObject

directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

Expand Down
62 changes: 56 additions & 6 deletions src/language/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ export type ASTNode =
| EnumTypeDefinitionNode
| EnumValueDefinitionNode
| InputObjectTypeDefinitionNode
| ScalarTypeExtensionNode
| ObjectTypeExtensionNode
| InterfaceTypeExtensionNode
| UnionTypeExtensionNode
| EnumTypeExtensionNode
| InputObjectTypeExtensionNode
| DirectiveDefinitionNode;

// Name
Expand Down Expand Up @@ -398,7 +403,7 @@ export type ObjectTypeDefinitionNode = {
+name: NameNode,
+interfaces?: Array<NamedTypeNode>,
+directives?: Array<DirectiveNode>,
+fields: Array<FieldDefinitionNode>,
+fields?: Array<FieldDefinitionNode>,
};

export type FieldDefinitionNode = {
Expand Down Expand Up @@ -427,7 +432,7 @@ export type InterfaceTypeDefinitionNode = {
+description?: StringValueNode,
+name: NameNode,
+directives?: Array<DirectiveNode>,
+fields: Array<FieldDefinitionNode>,
+fields?: Array<FieldDefinitionNode>,
};

export type UnionTypeDefinitionNode = {
Expand All @@ -436,7 +441,7 @@ export type UnionTypeDefinitionNode = {
+description?: StringValueNode,
+name: NameNode,
+directives?: Array<DirectiveNode>,
+types: Array<NamedTypeNode>,
+types?: Array<NamedTypeNode>,
};

export type EnumTypeDefinitionNode = {
Expand All @@ -445,7 +450,7 @@ export type EnumTypeDefinitionNode = {
+description?: StringValueNode,
+name: NameNode,
+directives?: Array<DirectiveNode>,
+values: Array<EnumValueDefinitionNode>,
+values?: Array<EnumValueDefinitionNode>,
};

export type EnumValueDefinitionNode = {
Expand All @@ -462,12 +467,25 @@ export type InputObjectTypeDefinitionNode = {
+description?: StringValueNode,
+name: NameNode,
+directives?: Array<DirectiveNode>,
+fields: Array<InputValueDefinitionNode>,
+fields?: Array<InputValueDefinitionNode>,
};

// Type Extensions

export type TypeExtensionNode = ObjectTypeExtensionNode;
export type TypeExtensionNode =
| ScalarTypeExtensionNode
| ObjectTypeExtensionNode
| InterfaceTypeExtensionNode
| UnionTypeExtensionNode
| EnumTypeExtensionNode
| InputObjectTypeExtensionNode;

export type ScalarTypeExtensionNode = {
kind: 'ScalarTypeExtension',
loc?: Location,
name: NameNode,
directives?: ?Array<DirectiveNode>,
};

export type ObjectTypeExtensionNode = {
+kind: 'ObjectTypeExtension',
Expand All @@ -478,6 +496,38 @@ export type ObjectTypeExtensionNode = {
+fields?: Array<FieldDefinitionNode>,
};

export type InterfaceTypeExtensionNode = {
kind: 'InterfaceTypeExtension',
loc?: Location,
name: NameNode,
directives?: ?Array<DirectiveNode>,
fields?: ?Array<FieldDefinitionNode>,
};

export type UnionTypeExtensionNode = {
kind: 'UnionTypeExtension',
loc?: Location,
name: NameNode,
directives?: ?Array<DirectiveNode>,
types?: ?Array<NamedTypeNode>,
};

export type EnumTypeExtensionNode = {
kind: 'EnumTypeExtension',
loc?: Location,
name: NameNode,
directives?: ?Array<DirectiveNode>,
values?: ?Array<EnumValueDefinitionNode>,
};

export type InputObjectTypeExtensionNode = {
kind: 'InputObjectTypeExtension',
loc?: Location,
name: NameNode,
directives?: ?Array<DirectiveNode>,
fields?: ?Array<InputValueDefinitionNode>,
};

// Directive Definitions

export type DirectiveDefinitionNode = {
Expand Down
5 changes: 5 additions & 0 deletions src/language/kinds.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export const INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';

// Type Extensions

export const SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension';
export const OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension';
export const INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension';
export const UNION_TYPE_EXTENSION = 'UnionTypeExtension';
export const ENUM_TYPE_EXTENSION = 'EnumTypeExtension';
export const INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension';

// Directive Definitions

Expand Down
Loading