-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(relay): Fix interop with server actions of next.js (#306)
- Loading branch information
Showing
5 changed files
with
164 additions
and
7 deletions.
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
43 changes: 43 additions & 0 deletions
43
packages/relay/transform/tests/fixture/eager-es-modules/next-15763/1/input.js
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,43 @@ | ||
import { graphql } from "relay-runtime"; | ||
import { revalidatePath } from "next/cache"; | ||
|
||
export async function setValue(string) { | ||
"use server"; | ||
|
||
// comment out the next two statements to successfully compile | ||
const taggedNode = graphql` | ||
mutation actionsSetThingMutation($value: String!) { | ||
setRocket(value: $value) { | ||
name | ||
} | ||
} | ||
` | ||
console.log({ taggedNode }) | ||
|
||
const response = await fetch("http://localhost:3000/graphql", { | ||
body: JSON.stringify({ | ||
// replace this query with the taggedNode value | ||
query: ` | ||
mutation actionsSetThingMutation($value: String!) { | ||
setThing(value: $value) { | ||
name | ||
} | ||
} | ||
`, | ||
variables: { | ||
value: string, | ||
}, | ||
}), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
method: "POST", | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
// the ui should flush this value when revalidated | ||
console.log(data); | ||
|
||
revalidatePath("/", 'page'); | ||
}; |
35 changes: 35 additions & 0 deletions
35
packages/relay/transform/tests/fixture/eager-es-modules/next-15763/1/output.js
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,35 @@ | ||
import __actionsSetThingMutation from "./__generated__/actionsSetThingMutation.graphql.ts"; | ||
import { graphql } from "relay-runtime"; | ||
import { revalidatePath } from "next/cache"; | ||
export async function setValue(string) { | ||
"use server"; | ||
// comment out the next two statements to successfully compile | ||
const taggedNode = __actionsSetThingMutation; | ||
console.log({ | ||
taggedNode | ||
}); | ||
const response = await fetch("http://localhost:3000/graphql", { | ||
body: JSON.stringify({ | ||
// replace this query with the taggedNode value | ||
query: ` | ||
mutation actionsSetThingMutation($value: String!) { | ||
setThing(value: $value) { | ||
name | ||
} | ||
} | ||
`, | ||
variables: { | ||
value: string | ||
} | ||
}), | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
method: "POST" | ||
}); | ||
const data = await response.json(); | ||
// the ui should flush this value when revalidated | ||
console.log(data); | ||
revalidatePath("/", 'page'); | ||
} | ||
; |
43 changes: 43 additions & 0 deletions
43
packages/relay/transform/tests/fixture/eager-es-modules/next-15763/2/input.js
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,43 @@ | ||
"use server"; | ||
|
||
import { graphql } from "relay-runtime"; | ||
import { revalidatePath } from "next/cache"; | ||
|
||
export async function setValue(string) { | ||
// comment out the next two statements to successfully compile | ||
const taggedNode = graphql` | ||
mutation actionsSetThingMutation($value: String!) { | ||
setRocket(value: $value) { | ||
name | ||
} | ||
} | ||
` | ||
console.log({ taggedNode }) | ||
|
||
const response = await fetch("http://localhost:3000/graphql", { | ||
body: JSON.stringify({ | ||
// replace this query with the taggedNode value | ||
query: ` | ||
mutation actionsSetThingMutation($value: String!) { | ||
setThing(value: $value) { | ||
name | ||
} | ||
} | ||
`, | ||
variables: { | ||
value: string, | ||
}, | ||
}), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
method: "POST", | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
// the ui should flush this value when revalidated | ||
console.log(data); | ||
|
||
revalidatePath("/", 'page'); | ||
}; |
35 changes: 35 additions & 0 deletions
35
packages/relay/transform/tests/fixture/eager-es-modules/next-15763/2/output.js
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,35 @@ | ||
"use server"; | ||
import __actionsSetThingMutation from "./__generated__/actionsSetThingMutation.graphql.ts"; | ||
import { graphql } from "relay-runtime"; | ||
import { revalidatePath } from "next/cache"; | ||
export async function setValue(string) { | ||
// comment out the next two statements to successfully compile | ||
const taggedNode = __actionsSetThingMutation; | ||
console.log({ | ||
taggedNode | ||
}); | ||
const response = await fetch("http://localhost:3000/graphql", { | ||
body: JSON.stringify({ | ||
// replace this query with the taggedNode value | ||
query: ` | ||
mutation actionsSetThingMutation($value: String!) { | ||
setThing(value: $value) { | ||
name | ||
} | ||
} | ||
`, | ||
variables: { | ||
value: string | ||
} | ||
}), | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
method: "POST" | ||
}); | ||
const data = await response.json(); | ||
// the ui should flush this value when revalidated | ||
console.log(data); | ||
revalidatePath("/", 'page'); | ||
} | ||
; |