Skip to content

Commit

Permalink
Merge pull request #191 from vektah/nullable-list-elements
Browse files Browse the repository at this point in the history
Support nullable list elements
  • Loading branch information
vektah authored Jul 14, 2018
2 parents 0780bf2 + e0bf6af commit 533dcba
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion codegen/type_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (n NamedTypes) getType(t common.Type) *Type {
if _, nonNull := t.(*common.NonNull); nonNull {
usePtr = false
} else if _, nonNull := t.(*common.List); nonNull {
usePtr = false
usePtr = true
} else {
if usePtr {
modifiers = append(modifiers, modPtr)
Expand Down
2 changes: 1 addition & 1 deletion example/dataloader/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/dataloader/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type Query {
customers: [Customer!]

# this method is here to test code generation of nested arrays
torture(customerIds: [[Int]]): [[Customer!]]
torture(customerIds: [[Int!]]): [[Customer!]]
}

type Customer {
Expand Down
2 changes: 1 addition & 1 deletion example/selection/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/selection/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Like implements Event {
}

type Query {
events: [Event]
events: [Event!]
}

scalar Time
18 changes: 9 additions & 9 deletions example/starwars/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions example/starwars/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The query type, represents all of the entry points into our object graph
type Query {
hero(episode: Episode = NEWHOPE): Character
reviews(episode: Episode!, since: Time): [Review]!
search(text: String!): [SearchResult]!
reviews(episode: Episode!, since: Time): [Review!]!
search(text: String!): [SearchResult!]!
character(id: ID!): Character
droid(id: ID!): Droid
human(id: ID!): Human
Expand All @@ -28,7 +28,7 @@ interface Character {
# The name of the character
name: String!
# The friends of the character, or an empty list if they have none
friends: [Character]
friends: [Character!]
# The friends of the character exposed as a connection with edges
friendsConnection(first: Int, after: ID): FriendsConnection!
# The movies this character appears in
Expand All @@ -52,13 +52,13 @@ type Human implements Character {
# Mass in kilograms, or null if unknown
mass: Float
# This human's friends, or an empty list if they have none
friends: [Character]
friends: [Character!]
# The friends of the human exposed as a connection with edges
friendsConnection(first: Int, after: ID): FriendsConnection!
# The movies this human appears in
appearsIn: [Episode!]!
# A list of starships this person has piloted, or an empty list if none
starships: [Starship]
starships: [Starship!]
}
# An autonomous mechanical character in the Star Wars universe
type Droid implements Character {
Expand All @@ -67,7 +67,7 @@ type Droid implements Character {
# What others call this droid
name: String!
# This droid's friends, or an empty list if they have none
friends: [Character]
friends: [Character!]
# The friends of the droid exposed as a connection with edges
friendsConnection(first: Int, after: ID): FriendsConnection!
# The movies this droid appears in
Expand All @@ -80,9 +80,9 @@ type FriendsConnection {
# The total number of friends
totalCount: Int!
# The edges for each of the character's friends.
edges: [FriendsEdge]
edges: [FriendsEdge!]
# A list of the friends, as a convenience when edges are not needed.
friends: [Character]
friends: [Character!]
# Information for paginating this connection
pageInfo: PageInfo!
}
Expand Down Expand Up @@ -125,7 +125,7 @@ type Starship {
# Length of the starship, along the longest axis
length(unit: LengthUnit = METER): Float!
# coordinates tracking this ship
history: [[Int]]
history: [[Int!]!]!
}
union SearchResult = Human | Droid | Starship
scalar Time
13 changes: 8 additions & 5 deletions test/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/resolvers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func (r *testResolvers) Query_date(ctx context.Context, filter models.DateFilter
return r.queryDate(ctx, filter)
}

func (r *testResolvers) Query_path(ctx context.Context) ([]models.Element, error) {
return []models.Element{{1}, {2}, {3}, {4}}, nil
func (r *testResolvers) Query_path(ctx context.Context) ([]*models.Element, error) {
return []*models.Element{{1}, {2}, {3}, {4}}, nil
}

func (r *testResolvers) Element_child(ctx context.Context, obj *models.Element) (models.Element, error) {
Expand Down

0 comments on commit 533dcba

Please sign in to comment.