<@U59R0U6BA> I am nor using Appolo, I use lokka fo...
# prisma-whats-new
a
@pier I am nor using Appolo, I use lokka for backend tasks. When you have relations it's not possible to do batching I believe, performance with mutation is really slow
n
@andrius hey, where do you make the queries from?
a
from Firebase functions
n
do you know where that code is run (physically)? 🙂
a
I made some time measure. It will take ~27 days to upload 10K records
Google cloud
I have no problems with speed when I upload to Elasticsearch
n
Can you control where the code is executed?
Like, in which global region
a
I guess I need to write to Firebase support
n
You can run multiple mutations in the same HTTP request, are you already doing that? https://www.graph.cool/docs/faq/graphql-multiple-requests-cahzai2eur
27 days for 10k records sounds way too much, I can run roughly 30 operations a second 🙂 Can you share more about your Firebase Cloud Function setup?
a
The real issue that I have few relations there
n
Are you using nested mutations?
a
yes
n
Why is having relations an issue?
a
because I need to wire it to main object
like adding photo object
n
That's something you can circumvent with nested mutations
are you talking about image files?
a
nope, just meta data
n
In general, I'm curious to learn more about your setup so we can optimize the performance together 🙂 What "layers" does your code run through before hitting the GraphQL API?
a
I get data from firebase, fill query with data and run it
it's really simple, no rocket science )
n
And this happens with Google Cloud functions? Why aren't you running a local script to do this instead?
You can - first get all data from FB locally - preprocess the data locally - run all necessary mutations to the GraphQL API
a
well, the real reason is to sync firebase data GraphQL. We have users that edit that data, so we need to update it real-time , to keep it in sync, So maybe one day we can switch to GraphQL. And Firebase functions is really good way to do that
It's fast, I have ElasticSearch sync there also, no performance issues
n
Ah, now I understand. Then the Google Cloud functions make more sense, if it's real time. However, why do you need to sync 10k records then? This doesn't sound like a real-time use case 🙂
a
actually it's more 100K
10K was just an example how slow it is now )
n
I am not sure about what use case we're currently talking, can you clarify that for me?
Do you need to sync 100k records in real-time? I can't imagine this use case right now 🙂
a
syncing UK suppliers database from Firebase to GraphQL. After that keep realtime sync to update new edited data, after all frontend/backend changes are ready switch to GraphQL
n
Ok 🙂 Then this is like a one-time import, right?
a
yes and no, we also have suppliers that update data daily , also new sign-ups, so we need to keep data in sync
n
Yep! It's easier to focus on one use case, otherwise I get quickly confused 😅 Which one do you want to talk about now?
The performance you describe is certainly unexpected and I believe we can find the cause of that together 😉
a
Well, for example we also have ElasticSearch that we use for search , and It keeps quite a lot of data for each supplier. I have Firebase function that send data to Elastic. It serve both purposes: it does real-time sync when supplier edit his data. Also when I need to update all record in Elastic (for example we added new fsearch field), I just trigger change on one fields one-by-one on all supplier record in Firebase, and then that function updated entire ElasticSearch. So I thought I can do the same with GraphQL
n
I know too little about both your Firebase schema as well as your Graphcool schema. How directly does your Firebase schema map to your GraphQL schema?
a
give me a sec.. i'll prepare some example
👍 1
So, in Firebase we have json object
in GraphQL for each Section we have a separate table
the lokka quiery is
Copy code
(
    $supplierAccountEmail: String!,
    $supplierCategory: String!,
    $supplierId: String!,
		$accAssociations: Json!,
		$faqsAnswers: Json!,
		$featuredIn: Json!,
		$industryAwards: Json!,
		$videos: [Json!],
		$detailedDescription: String!,
		$prefList: [Json!]
  )
  {
    createSupplier (
			accreditationsAssociations: [$accAssociations]
			appearsInMainSearch: ${V.verifyF(supplier.appearsInMainSearch)}
			benefit: {
				bbDiscount: "${V.verifyS(supplier.bbDiscount)}"
				bbDiscountOtherDetails: "${V.verifyS(supplier.bbDiscountOtherDetails)}"
				bbGift: "${V.verifyS(supplier.bbGift)}"
				bbGiftOtherDetails: "${V.verifyS(supplier.bbGiftOtherDetails)}"
				bbSpecialOffer: "${V.verifyS(supplier.bbSpecialOffer)}"
			}
			direction:{
				nearestAirport: "${V.verifyS(supplier.nearestAirport)}"
				nearestMotorway: "${V.verifyS(supplier.nearestMotorway)}"
				nearestTown: "${V.verifyS(supplier.nearestTown)}"
				nearestTrainStation: "${V.verifyS(supplier.nearestTrainStation)}"
				travelNotes: "${V.verifyS(supplier.travelNotes)}"
			}
			email: "${V.verifyS(supplier.email)}"
			experience: {
				noOfPeopleInTeam: ${V.verifyN(supplier.noOfPeopleInTeam)}
				noOfWeddingsHosted: "${V.verifyS(supplier.noOfWeddingsHosted)}"
				publicLiabilityInsurance: ${V.verifyF(supplier.publicLiabilityInsurance)}
				yearBusinessWasEstablished: ${V.verifyN(supplier.yearBusinessWasEstablished)}
			}
			idx: $supplierId
			publicIdx: "${supplier.publicId}"
			slug: $supplierCategory
			name: "${supplier.name}",
			supplierEmail: $supplierAccountEmail
			faqsAnswers: [$faqsAnswers]
			featuredIn: [$featuredIn]
			industryAwards: [$industryAwards]
			fakeProfile: ${V.verifyF(supplier.fakeProfile)}
			geocoderVerified: "${V.verifyS(supplier.geocoderVerified)}"
			hideFirstAddressLine: ${V.verifyF(supplier.hideFirstAddressLine)}
			invite: "${V.verifyS(supplier.invite)}"
			contact: {
				address: "${supplier.address}"
				country: "${supplier.country}"
				county: "${supplier.county}"
				lat: ${supplier.lat}
				lng: ${supplier.lng}
				postcode: "${supplier.postcode}"
				town: "${supplier.town}"
				phone: "${supplier.phone}"
				website: "${V.verifyS(supplier.website)}"
			}
			manualCheck: {
				completed: ${V.verifyF(supplier.manualCheck.completed)}
				dateManualCheck: "${V.verifyN(supplier.manualCheck.dateManualCheck)}"
				initials: "${V.verifyS(supplier.manualCheck.initials)}"
				poop: ${V.verifyF(supplier.manualCheck.poop)}
				star: ${V.verifyF(supplier.manualCheck.star)}
				toBeDeleted: ${V.verifyF(supplier.manualCheck.toBeDeleted)}
			}
...........
			specialist: {
				asianWeddingSpecialist: ${supplier.specialistWeddingSection.asianWeddingSpecialist}
				jewishWeddingSpecialist: ${supplier.specialistWeddingSection.jewishWeddingSpecialist}
				muslimWeddingSpecialist: ${supplier.specialistWeddingSection.muslimWeddingSpecialist}
				otherWeddingSpecialist: ${supplier.specialistWeddingSection.otherWeddingSpecialist}
				otherWeddingSpecialistDetails: "${supplier.specialistWeddingSection.otherWeddingSpecialistDetails}"
			}
			supplierDeleted: ${V.verifyF(supplier.supplierDeleted)}
			supplierDeletedDate: "${V.convertToDateTimeTimestamp(supplier.supplierDeletedDate)}"
			supplierRegistered: ${V.verifyF(supplier.supplierRegistered)}
			userVerified: ${V.verifyF(supplier.userVerified)}
			videos: $videos
			description: "${V.verifyS(supplier.description)}"
			detailedDescription: $detailedDescription

    ) {
			id
      idx
      slug
    }
  }`;
then I have similar queries for each Section
that is wired after to each main object
Copy code
const mutationQueryA = `{
				addToSupplierOnEndorsement(
			    endorsementsEndorsementId:"${rezM.createEndorsement.id}"
			    supplierSupplierId:"${cQID}"
			  ) {
			    endorsementsEndorsement{
			      id
			      idx
			    }
			  }
			}`;

		const rezA = await client.mutate(mutationQueryA);
it's one-to-many realtion
and that's about it
n
so you can't suppy ALL
endorsements
at the same time?
a
well, endorsment and photo I can
but there is other Sections that are different for each supplier that can't
n
ok
if you run this
createSupplier
mutation, how long does it take?
a
have to run some code..give me few minutes
8889ms
n
how many records are you creating with a single mutation?
it contains a lot of nested arguments 🙂
a
8
n
And this is run through Google Code?
a
yes
n
what if you run a similar mutation locally?
a
well, I am actually really far away, working remotely
I can deploy that code to DigitalOcean and try to run
n
sure, try to run it from Ireland if possible 😉
a
our DO is in UK, so it's close enough
689ms
n
Interesting
So that's a factor of 10 🙂
a
yes, surprising
n
and given that you're creating 8 (or 9?) records, it's pretty good actually
now it would be interesting where your Google Code is executed
a
i will try to find out
n
awesome!