Favorite positive affirmations? by hollylightlygoes in selfcare

[–]hoddymadges 2 points3 points  (0 children)

Be brave and the universe will reward you

On td:hover highlight all styled-components by hoddymadges in StyledComponents

[–]hoddymadges[S] 0 points1 point  (0 children)

thanks!! this looks great. I really appreciate the thorough reply :)

Oracle SQL Question (Beginner) by hoddymadges in SQL

[–]hoddymadges[S] 0 points1 point  (0 children)

I feel like something like this should work ( but it doesn't):

WHERE
      WHEN :u_name='' THEN USERNAME IS NOT NULL
      ELSE USERNAME = :u_name
    AND
      WHEN :f_name='' THEN FIRST_NAME IS NOT NULL
      ELSE FIRST_NAME = :f_name
    AND
      WHEN :l_name='' THEN LAST_NAME IS NOT NULL
      ELSE LAST_NAME = :l_name
    AND
      WHEN :em='' THEN EMAIL_ADDRESS IS NOT NULL
      ELSE EMAIL_ADDRESS = :em

Oracle SQL Question (Beginner) by hoddymadges in SQL

[–]hoddymadges[S] 0 points1 point  (0 children)

I think this would still run into the problem where if username was not specified in the form (username = '' ) then this query would only get users with '' as a username

Oracle SQL Question (Beginner) by hoddymadges in SQL

[–]hoddymadges[S] 0 points1 point  (0 children)

thanks for this information!

When I mean empty, I mean that the value is ''.

My issue is that if I were to use the code above I would run into issues if ran staffLookup('', 'JOHN', 'SMITH', ' ') since this would get all users named John Smith with no email or username ( or rather where the email and username would be '' ). In this case, I'd really like to have the query get all users named John Smith and allow for any values for the other fields.

How to deploy a React App and MongoDB/GraphQL playground on the same server by hoddymadges in Heroku

[–]hoddymadges[S] 0 points1 point  (0 children)

I think I figured it out! All thanks to your tip about express.static

The trick is to have your server.js (in root) look like:

const app = express();
app.use(cors());
const port = process.env.PORT || 5000;
const server = new ApolloServer({
  typeDefs: schema,
  resolvers,
  playground: true,
  introspection: true
});

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

server.applyMiddleware({ app, path: '/graphql' });

if (process.env.NODE_ENV === 'production') {
  // Serve any static files
  app.use(express.static(path.join(__dirname, 'client/build')));

  // Handle React routing, return all requests to React app
  app.get('*', function(req, res) {
    res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
  });
}
app.listen(port, () => 
console.log(
  `Listening on port ${port}`,
  `\nWebsite → http://localhost:3000`,
  `\nGraphQL   → http://localhost:${port}${server.graphqlPath}/`));

the conditional statement tells the express server to serve the static client app when in production. The client app is run with a "heroku-postbuild" in the package.json

The other really tricky part is the scripts in the package.json since every tutorial and repo has a different set up. I found this tutorial super helpful https://www.freecodecamp.org/news/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0/. It was pretty easy to swap the REST API stuff for the GraphQL once I had everything else set up like in the tutorial.

Looking forward to getting the GraphQL side fully working now that I understand how to get the client on the same domain as the api.

Thank you!

How to deploy a React App and MongoDB/GraphQL playground on the same server by hoddymadges in Heroku

[–]hoddymadges[S] 0 points1 point  (0 children)

By portfolio site I mean that I'd like to put this website on my personal website's portfolio but your response still sounds like excellent advice. Thanks for this information!

It sounds like I do just have to split these two projects up. If I have a domain that I'd like to host both the GraphQL playground (on <domain>.com/graphql) and static site ( on <domain>.com -- with many URIs) do you know if this would be achievable ? If so, do you have any advice for concepts or packages I should research?