Skip to content

Commit

Permalink
chore(gatsby): Update to GraphQL 16 (#36813)
Browse files Browse the repository at this point in the history
* yolo

* also update codemods

* update graphql-compose

* fix type errors

* change graphql func signature

* update test snapshots

* fix GraphQLList in transformer-sharp
  • Loading branch information
LekoArts committed Oct 19, 2022
1 parent e574964 commit 9f840ad
Show file tree
Hide file tree
Showing 47 changed files with 307 additions and 341 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@babel/plugin-syntax-typescript": "^7.14.0",
"@babel/runtime": "^7.15.4",
"execa": "^5.1.1",
"graphql": "^15.8.0",
"graphql": "^16.6.0",
"jscodeshift": "^0.12.0",
"recast": "^0.20.5"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ export const query = graphql`{
gatsbyImageData(width: 125, height: 125, layout: FIXED)
}
}
}
`
}`
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ const result = graphql(`{
gatsbyImageData(layout: FULL_WIDTH)
}
}
}
`)
}`)
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ export const query = graphql`{
gatsbyImageData(width: 500, layout: CONSTRAINED)
}
}
}
`
}`
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ export const query = graphql`{
gatsbyImageData(placeholder: TRACED_SVG, layout: CONSTRAINED)
}
}
}
`
}`
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export const query = graphql`{
gatsbyImageData(placeholder: TRACED_SVG, layout: FULL_WIDTH)
}
}
}
`
}`
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ export const query = graphql`{
)
}
}
}
`
}`
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export const Hero: React.SFC = ({ children }) => {
gatsbyImageData(layout: FULL_WIDTH)
}
}
}
`);
}`);
return (
<GatsbyImage
image={data.file.childImageSharp.gatsbyImageData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,24 @@ describe(transformName, () => {
it(`single field (root field), no order`, () => {
expect(run(`allMarkdownRemark(sort: {fields: excerpt})`))
.toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {excerpt: ASC})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {excerpt: ASC})
}\`"
`)
})

it(`single field (nested field), no order`, () => {
expect(
run(`allMarkdownRemark(sort: {fields: frontmatter___nested___date})`)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {nested: {date: ASC}}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {nested: {date: ASC}}})
}\`"
`)
})

it(`single field, single order (ASC)`, () => {
Expand All @@ -62,13 +60,12 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: ASC}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: ASC}})
}\`"
`)
})

it(`single field, single order (DESC)`, () => {
Expand All @@ -80,25 +77,23 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}\`"
`)
})

it(`list with single field, no order`, () => {
expect(run(`allMarkdownRemark(sort: {fields: [frontmatter___date]})`))
.toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: ASC}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: ASC}})
}\`"
`)
})

it(`list with multiple fields, no order`, () => {
Expand All @@ -107,15 +102,14 @@ describe(transformName, () => {
`allMarkdownRemark(sort: {fields: [frontmatter___priority, frontmatter___date]})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(
sort: [{frontmatter: {priority: ASC}}, {frontmatter: {date: ASC}}]
)
}
\`"
`)
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(
sort: [{frontmatter: {priority: ASC}}, {frontmatter: {date: ASC}}]
)
}\`"
`)
})

it(`single field, list with single order`, () => {
Expand All @@ -127,13 +121,12 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}\`"
`)
})

it(`single field, list with multiple orders`, () => {
Expand All @@ -146,13 +139,12 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}\`"
`)
})

it(`list with single field, list with single order`, () => {
Expand All @@ -164,13 +156,12 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}
\`"
`)
export const q = graphql\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}})
}\`"
`)
})

it(`list with multiple fields, list with single order`, () => {
Expand All @@ -182,15 +173,14 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(
sort: [{frontmatter: {isFeatured: DESC}}, {frontmatter: {date: ASC}}]
)
}
\`"
`)
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(
sort: [{frontmatter: {isFeatured: DESC}}, {frontmatter: {date: ASC}}]
)
}\`"
`)
})

it(`list with multiple fields, list with multiple orders`, () => {
Expand All @@ -202,15 +192,14 @@ describe(transformName, () => {
})`
)
).toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(
sort: [{frontmatter: {isFeatured: DESC}}, {frontmatter: {date: DESC}}]
)
}
\`"
`)
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
allMarkdownRemark(
sort: [{frontmatter: {isFeatured: DESC}}, {frontmatter: {date: DESC}}]
)
}\`"
`)
})
})

Expand Down Expand Up @@ -250,13 +239,12 @@ describe(transformName, () => {
it(`root field`, () => {
expect(run(`distinct(field: frontmatter___category)`))
.toMatchInlineSnapshot(`
"import { graphql } from \\"gatsby\\"
"import { graphql } from \\"gatsby\\"
export const q = graphql\`{
distinct(field: {frontmatter: {category: SELECT}})
}
\`"
`)
export const q = graphql\`{
distinct(field: {frontmatter: {category: SELECT}})
}\`"
`)
})

it(`nested field`, () => {
Expand All @@ -266,8 +254,7 @@ describe(transformName, () => {
export const q = graphql\`{
distinct(field: {frontmatter: {nested_category: SELECT}})
}
\`"
}\`"
`)
})
})
Expand Down Expand Up @@ -314,17 +301,16 @@ describe(transformName, () => {
path: join(__dirname, `..`, `..`, `example.js`),
})
).toMatchInlineSnapshot(`
"exports.createPages = ({ graphql, actions }) => {
const { data } = graphql(\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}}) {
nodes {
id
}
}
}
\`)
}"
`)
"exports.createPages = ({ graphql, actions }) => {
const { data } = graphql(\`{
allMarkdownRemark(sort: {frontmatter: {date: DESC}}) {
nodes {
id
}
}
}\`)
}"
`)
})

it(`graphql("...")`, () => {
Expand All @@ -345,8 +331,7 @@ describe(transformName, () => {
id
}
}
}
\`)
}\`)
}"
`)
})
Expand All @@ -369,8 +354,7 @@ describe(transformName, () => {
id
}
}
}
\`)
}\`)
}"
`)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"fs-extra": "^10.1.0",
"gatsby-core-utils": "^4.0.0-next.1",
"gatsby-sharp": "^1.0.0-next.0",
"graphql-compose": "^9.0.7",
"graphql-compose": "^9.0.9",
"import-from": "^4.0.0",
"joi": "^17.4.2",
"mime": "^3.0.0",
Expand All @@ -70,7 +70,7 @@
},
"peerDependencies": {
"gatsby": "^5.0.0-alpha-v5",
"graphql": "^15.0.0"
"graphql": "^16.0.0"
},
"files": [
"dist/"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ type Mutation {
type Wrapper {
query: String
}
"
}"
`;

exports[`StripNonQueryTransform works 1`] = `
"type Query {
query: String
}
"
}"
`;
Loading

0 comments on commit 9f840ad

Please sign in to comment.