File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import node from '@astrojs/node';
33import svelte from '@astrojs/svelte' ;
44import tailwindcss from '@tailwindcss/vite' ;
55import { defineConfig } from 'astro/config' ;
6+ import { JsxEmit } from 'typescript' ;
67
78const PREVIEW = process . env . PREVIEW_DEPLOYMENT === 'true' ;
89
@@ -38,7 +39,8 @@ export default defineConfig({
3839
3940 vite : {
4041 define : {
41- 'process.env' : process . env ,
42+ 'process.env.TWENTY_AUTH' : `${ process . env . TWENTY_AUTH } ` ,
43+ 'process.env.TWENTY_GRAPHQL_URL' : `${ process . env . TWENTY_GRAPHQL_URL } ` ,
4244 } ,
4345 plugins : [ tailwindcss ( ) ] ,
4446 } ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export const prerender = false;
22import type { APIRoute } from 'astro' ;
33
44import { gql , GraphQLClient } from 'graphql-request' ;
5+
56export const POST : APIRoute = async ( { request } ) => {
67 const requiredFields = [
78 'firstName' ,
@@ -69,31 +70,33 @@ export const POST: APIRoute = async ({ request }) => {
6970
7071 // With the replace method the the quotes from the property keys (from JSON) are removed, because graphql requires them unquoted
7172 const mutation = gql `
72- mutation {
73- createPerson(data: ${ JSON . stringify ( personData ) . replace ( / " ( [ ^ " ] + ) " : / g, '$1:' ) } ) {
73+ mutation SupportFromMutation(
74+ $personData: PersonCreateInput
75+ $fordermitgliedschaftData: FordermitgliedschaftCreateInput
76+ ) {
77+ createPerson(data: $personData) {
7478 id
7579 createdAt
7680 }
77- createFordermitgliedschaft(
78- data: ${ JSON . stringify ( fordermitgliedschaftData ) . replace ( / " ( [ ^ " ] + ) " : / g, '$1:' ) }
79- ) {
81+ createFordermitgliedschaft(data: $fordermitgliedschaftData) {
8082 id
81- monatlicherForderbeitrag {
82- amountMicros
83- currencyCode
84- }
83+ createdAt
8584 }
8685 }
8786 ` ;
8887 console . log ( mutation ) ;
88+ const variables = {
89+ fordermitgliedschaftData,
90+ personData,
91+ } ;
8992 //TODO: link the Fordermitgliedschaft with the person
9093 interface ResponseData {
9194 createPerson : {
9295 createdAt : string ;
9396 id : string ;
9497 } ;
9598 }
96- const response = await graphQLClient . request < ResponseData > ( mutation ) ;
99+ const response = await graphQLClient . request < ResponseData > ( mutation , variables ) ;
97100 console . log ( response ) ;
98101 } catch ( error ) {
99102 console . error ( error ) ;
You can’t perform that action at this time.
0 commit comments