-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(visitor-plugin-common): avoid reading from null values #9709
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-codegen/visitor-plugin-common': patch | ||
--- | ||
|
||
Avoid reading from null values when selection sets only contain fragments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const MY_QUERY = /* GraphQL */ ` | ||
fragment CartLine on CartLine { | ||
id | ||
quantity | ||
} | ||
|
||
query Test { | ||
cart { | ||
lines { | ||
nodes { | ||
...CartLine | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
export type Maybe<T> = T | null; | ||
export type InputMaybe<T> = Maybe<T>; | ||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; | ||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> }; | ||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> }; | ||
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never }; | ||
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; | ||
/** All built-in and custom scalars, mapped to their actual values */ | ||
export type Scalars = { | ||
ID: { input: string; output: string }; | ||
String: { input: string; output: string }; | ||
Boolean: { input: boolean; output: boolean }; | ||
Int: { input: number; output: number }; | ||
Float: { input: number; output: number }; | ||
}; | ||
|
||
export type BaseCartLine = { | ||
id: Scalars['String']['output']; | ||
quantity: Scalars['Int']['output']; | ||
}; | ||
|
||
export type BaseCartLineConnection = { | ||
id: Scalars['String']['output']; | ||
nodes: Array<BaseCartLine>; | ||
}; | ||
|
||
export type Cart = { | ||
id: Scalars['String']['output']; | ||
lines: BaseCartLineConnection; | ||
}; | ||
|
||
export type CartLine = BaseCartLine & { | ||
id: Scalars['String']['output']; | ||
quantity: Scalars['Int']['output']; | ||
}; | ||
|
||
export type ComponentizableCartLine = BaseCartLine & { | ||
id: Scalars['String']['output']; | ||
quantity: Scalars['Int']['output']; | ||
}; | ||
|
||
export type QueryRoot = { | ||
cart?: Maybe<Cart>; | ||
}; | ||
|
||
export type CartLineFragment = { id: string; quantity: number }; | ||
|
||
export type TestQueryVariables = Exact<{ [key: string]: never }>; | ||
|
||
export type TestQuery = { cart?: { lines: { nodes: Array<{ id: string; quantity: number }> } } | null }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
schema { | ||
query: QueryRoot | ||
} | ||
|
||
interface BaseCartLine { | ||
id: String! | ||
quantity: Int! | ||
} | ||
|
||
type BaseCartLineConnection { | ||
id: String! | ||
nodes: [BaseCartLine!]! | ||
} | ||
|
||
type Cart { | ||
id: String! | ||
lines: BaseCartLineConnection! | ||
} | ||
|
||
type CartLine implements BaseCartLine { | ||
id: String! | ||
quantity: Int! | ||
} | ||
|
||
type ComponentizableCartLine implements BaseCartLine { | ||
id: String! | ||
quantity: Int! | ||
} | ||
|
||
type QueryRoot { | ||
cart: Cart | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relevant.length === 0
will betrue
for[null]
so it exits before declaringhasUnions
.