Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Just letting you guys know I'm rebuilding an api using apollo-server as my graphql base, and prisma as my orm and it's pretty good. I'm liking graphql, a lot about it makes sense, and I'm loving how prisma solves graphql's n+1 problem. It basically waits for nextTick inside of node and then smashes all of the queries together that it received best it can.

Really impressed I don't have to think about what my database is doing most the time.

Adbot
ADBOT LOVES YOU

prom candy
Dec 16, 2005

Only I may dance
Having built a GraphQL server with rails and activerecord that sounds really nice. Because I wish my graphql server was a REST server.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I looked at how to build a graphql server and the first thing I thought was that's a n+1 nightmare. Then I found out people are apparently aware because it's been used for the last couple of years or so and that's why prisma in part was built. Prisma also supports root resolution, from what I'm reading, I think. You can give it the gql string and it'll make sql queries that fulfil the entire thing.

Don't believe it.

In the meantime, I'm perfectly happy with the "automatically smash as much of the queries together as you can afterwards" approach.

prom candy
Dec 16, 2005

Only I may dance
Just checking it out, this looks great. I want to get off Rails so bad but it's never gonna happen.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
I have a NextJS app I'm working on that allows you to select filters to search through a list of hotels (such as has a pool, has a beach view etc) my question is since this is going to be a multiselect box, what's you experts opinion of the best way to do something like that but keeping UI and mobile design in mind? There will probably end up being about thirty filters so I don't think it'd be best to lay them all out and looking into materialuis multiselect it doesn't really work the best design wise imho.

Thanks!

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Depends what your using as your fancy css/whatever framework, there's mutiselect in most of them. Or you can just use normal plain old boring `<select multiple>`

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I have an api with two different types of endpoints each requiring a different authorization header.

One is user based operations where you need to provide the appropriate jwt as a header in the format `Bearer <token>`, which you get from hitting the login. But I have another set of author based operations for which both an `authorId` and a `key` need to be provided. The key is something that's generated and then encrypted before being put in the database.

When the request is received, the Author record is looked up and the key is compared using bcrypt. But regardless. What type of authorization header is that? Is it `Basic <md5(authorId:key)>`? (just realised that wouldn't make sense)


Or maybe the key is checked against whatever is being operated on after the endpoint is hit, so I don't really need the authorId up front, what type of authorization header is that? Is it `Bearer <key>`?

Think I might go with a custom type and use `AuthorKey <key>` for my authorization header.

Nolgthorn fucked around with this message at 18:24 on Feb 24, 2021

The Dave
Sep 9, 2003

Empress Brosephine posted:

I have a NextJS app I'm working on that allows you to select filters to search through a list of hotels (such as has a pool, has a beach view etc) my question is since this is going to be a multiselect box, what's you experts opinion of the best way to do something like that but keeping UI and mobile design in mind? There will probably end up being about thirty filters so I don't think it'd be best to lay them all out and looking into materialuis multiselect it doesn't really work the best design wise imho.

Thanks!


This sounds like a content strategy question more than anything. Is there a way to categorize, prioritize, or present the filters in a way that doesn't require me to look at all 30? If there is categorization, can it be split across a series of selects? There's probably a thousand mobile sites to pull examples from that have complex filtering.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
That's a good idea, I could distill it down a bit. The other thought was to do a autocomplete type thing instead which might work. I actually couldn't think of any examples to pull from so if you know any lol

The Dave
Sep 9, 2003

Autocomplete implies I know what filters to look for (and more specifically your labeling matching my expectations).

I was thinking hotel sites (like expedia), car sites (like car gurus), or furniture sites (like wayfair).

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I think airbnb just fills the page with search filters and doesn't hide any of them, but they're organized under categories.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Airbnb is a great example and I just took a look and might steal their implementation. They start off with a "Where do you want to stay?" Which wouldake sense in my situation also. I would just have to figure out how to map a town to a zip code or county I guess lol. Luckily I'm only dealing with one state and maybe 50 zip codes

Impotence
Nov 8, 2010
Lipstick Apathy

Empress Brosephine posted:

Airbnb is a great example and I just took a look and might steal their implementation. They start off with a "Where do you want to stay?" Which wouldake sense in my situation also. I would just have to figure out how to map a town to a zip code or county I guess lol. Luckily I'm only dealing with one state and maybe 50 zip codes

The phrase you're looking for is geocoding / reverse geocoding

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Blessed, thank you so much :worship:

I was going to code a thing otherwise that physically looks up the county for the city. Luckily the state is very small and doesn't have much so it wouldn't have been that tororous

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
I didn't realize geocaching or w/e costs money so I instead downloaded a json file of all the cities and counties in the state which seems to work. My question is and I can't really seem to figure this out, is there a way to turn that JSON into a GraphQL db?

Impotence
Nov 8, 2010
Lipstick Apathy

Empress Brosephine posted:

I didn't realize geocaching or w/e costs money so I instead downloaded a json file of all the cities and counties in the state which seems to work. My question is and I can't really seem to figure this out, is there a way to turn that JSON into a GraphQL db?

There's a handful that do 10k-100k a month for free which is fine for a hobby site

What are you trying to accomplish with gql?

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
This is a commercial site that averages about 100k page views in a month so that would probably work. I was just trying to use it to allow people to search by a city they're visiting, but I think I managed to do that by just using a JSON object of the cities, which is cool because it allows me to add extra data like county and region. Although the file is about 58kbs :(.

I'm wondering if turning it into a graphql server with apollo would be more efficient / better.

Impotence
Nov 8, 2010
Lipstick Apathy
It's going to be automatically compressed anyway

spiritual bypass
Feb 19, 2008

Grimey Drawer
It would probably be way smaller as CSV if you want to make parsing a little more complex

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Didn't even think of a csv, I'll try that. Thanks for the help everyone

Ima Computer
Oct 28, 2007

Stop all the downloading!

Help computer.
A 50-something KB JSON is probably smaller than most of the images on your page. Sure, it has some parsing cost, but it's a negligible amount. It's certainly not a big enough problem to be worth exploring other encoding formats which would require custom parsing code and likely result in the same if not worse performance. Sticking with JSON gives you a native parser implementation from the browser.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

fireraiser posted:

A 50-something KB JSON is probably smaller than most of the images on your page. Sure, it has some parsing cost, but it's a negligible amount. It's certainly not a big enough problem to be worth exploring other encoding formats which would require custom parsing code and likely result in the same if not worse performance. Sticking with JSON gives you a native parser implementation from the browser.

a few years back, a software architect, faced with an service returning large, complicated JSON (like 1mb+), started thinking "hey, maybe we should use something like protobuf instead of JSON so we can get smaller filesize and better serialization performance" unfortunately, the primary consumer of this service was js running in a browser. let's just say that it's very difficult to beat the deserialization performance of large, complicated json in the browser (want to say protobuf deserialization in the browser of an equivalent object was some ridiculous factor like 500x slower).

MrMoo
Sep 14, 2000

Yup, protobuf in the browser doesn’t have many benefits. I found MsgPack had a good compromise, it’s the combination of decode time and network transit time. JSON is supposedly the best on decode times but the wire speed is inherently costly.

Supporting MsgPack with JSON compatibility is a good option, but also consider you can push decode into a WebWorker thread and not block the UI.

Impotence
Nov 8, 2010
Lipstick Apathy
It's probably because json.parse is native code in browsers while the others have to be parsed in js

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Biowarfare posted:

It's probably because json.parse is native code in browsers while the others have to be parsed in js

json.parse implemented in script is essentially eval(), with regex run on the input text beforehand to make sure the passed in json text isn't dangerous. Going to be pretty difficult to beat JSON deserialization performance in js using any other kind of serialization format. (The native parser is an improvement over the script-based parser, but even the script based json parser is still very fast).

Impotence
Nov 8, 2010
Lipstick Apathy
Yeah, it's just going to be hard to beat this because it's native compared to everything else (like msgpack, etc)

though the big thing here is that for 50KB of data it quite literally doesn't matter what content type you put it in or how you parse it barring extreme edge cases, your react component will probably take more visible time to render than that

Only registered members can see post attachments!

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



The polyfill is the thing you use if you don't have native support

You'll also probably need a priest to do an exorcism and a therapist for after it's all over

frogbs
May 5, 2004
Well well well
This might be a better question for the hosting thread, but here goes.

For any solo/smaller dev shops out there, how do you deal with customers that expect that because you're handling their website that you'll also handle their email?

After this has come up a few times for me, i've been upfront that I don't handle email support, which has surprised some clients. Just this week we went to launch a site for someone, and at the end of the site approval/launch email the client said "and let us know when you're done transitioning over our email too!", without it ever coming up before. I understand there's some overlap, especially with DNS changes, but to me they are separate disciplines, and email is way more mission critical in most cases. Maybe I should be OK with being a 'one stop shop' for smaller clients, but whenever i've tried to do that it's become pretty burdensome vs. how much the clients can pay.

The Dave
Sep 9, 2003

You should have very very clear expectations for outputs in your SOW / work order / contract and there should be an understanding that if it's not listed in that signed agreement it is not part of the work.

If this is a particular delicate topic then you might want to go out of your way to include a note that email specifically is not included.

If it's something you could provide but don't like doing just charge a really high price for it, so the client that is willing to pay for it makes it worth it for you.

frogbs
May 5, 2004
Well well well

The Dave posted:

You should have very very clear expectations for outputs in your SOW / work order / contract and there should be an understanding that if it's not listed in that signed agreement it is not part of the work.

If this is a particular delicate topic then you might want to go out of your way to include a note that email specifically is not included.

If it's something you could provide but don't like doing just charge a really high price for it, so the client that is willing to pay for it makes it worth it for you.

Thanks, I think you're right. We don't mention email anywhere in our contracts, but maybe it's time we specifically add "we aren't responsible for your email". I think part of it is the kind of clients we're getting that just assume we're going to take care of anything related to a computer, even though it's not in the contract and never discussed. Our sales people usually ask "well, can't we just help them out?". Well, not for free!

Impotence
Nov 8, 2010
Lipstick Apathy
I had a freelance web dev client [same one for all of these] ask me:
- where to pirate poo poo and if i could get him cracked vegas pro
- if we could add a 200mb full screen background video to the front page
- what cpu to buy for his personal gaming pc
- if he should invest in bitcoin
- why the site is slow [on a phone, in a hurricane on 2g-3g fallback]
- how to bypass browsers muting autoplay videos

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
The company I contact for wants me to do email and I always tell them to talk to a IT person instead. I'm ok setting up something like a new gsuite account but I will not touch email migration.

Ima Computer
Oct 28, 2007

Stop all the downloading!

Help computer.
For small clients, grab a reseller account from MXRoute to sell to them.

frogbs
May 5, 2004
Well well well

fireraiser posted:

For small clients, grab a reseller account from MXRoute to sell to them.

That looks like a good service! For me at least, the issue isn’t having a service to
sell them (I’d probably just set them up with Google apps), but more that now I’m on the hook for every email support issue. “How do I set email up on my new phone”, “why is this going to spam?”, etc. For the clients I’ve helped with it, it’s always taken more time than I thought it would.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Super helpful suggestion with mxroute. Email is hell and everyone treats it like it's no big deal, I'd rather build a full app than set up an email address.

Tei
Feb 19, 2011
Probation
Can't post for 5 days!
most servers use gzip to send text, so if you are delivering JSON, is very possible that the text you are sending is transported has a binary compressed stream, so instead of 400KB of data, the browser is downloading 40KB of data

unpacking json in the browser is trivial, because JSON is esentially javascript it evaluate

still using large json files on the clientside is kind of a red flag and probably would byte people sooner or later... like... Sortering is anything but simple, if you are sorting data on the clientside, you are probably doing it wrong, ...thats what databases are for.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Run into a bit of a pain point regarding `apollo-server` that I was praising before.

I need static files in conjunction with my graphql server, which should be easy because I mean already anyway by default graphql is running at `/graphql` and is using http. But every document in the world talking about serving static files suggests expressjs or koa, or one of these other things which have specialised libraries for use with apollo server.

Really just need `node-static` honestly, running on node's built-in `http`. but nowhere seems to talk about it. I thought that would be the most basic example, how to use apollo server with node http.

It's a long shot but does anyone know how to do it?

Otherwise I'm gonna have to dig into the express, apollo-server-express, and apollo-server codebases just to figure it out.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
After peering under the hood apollo server is using express anyway. Never peer under the hood.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Yeah I think I was just overthinking my problems with the JSON thing and trying to make a simple app into something more than it should be.

Thanks for all the help!

Adbot
ADBOT LOVES YOU

Violator
May 15, 2003


frogbs posted:

but more that now I’m on the hook for every email support issue. “How do I set email up on my new phone”, “why is this going to spam?”, etc. For the clients I’ve helped with it, it’s always taken more time than I thought it would.

Yeah, the support is a nightmare.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply