question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cell Query Operation name not camelCase-d if use underscore in generation

See original GitHub issue

As of v0.14.0, cell queries now get an operation name to work with Storybook:

See: https://github.com/redwoodjs/redwood/pull/867

Example:

export const QUERY = gql`
- query {
+ query TestQuery {
    userProfile {
     id
   }
  }
`

I created a cell via the generator:

yarn rw g cell my_sites

and

✔ Generating cell files...
    ✔ Writing 
`./web/src/components/MySitesCell/MySitesCell.mock.j
s`...
    ✔ Writing 
`./web/src/components/MySitesCell/MySitesCell.storie
s.js`...
    ✔ Writing 
`./web/src/components/MySitesCell/MySitesCell.test.j
s`...
    ✔ Writing `./web/src/components/MySitesCell/MySi
tesCell.js`...
✨  Done in 1.57s.

the files, used the MySite upper camelCasing.

However, my query operation is

export const QUERY = gql`
  query my_sitesQuery {
    mySites {
      id
    }
  }
`

When I generated SitesCell it is

export const QUERY = gql`
  query sitesQuery {
    sites {
      id
    }
  }
`

I expected either

query MySitesQuery {

or

``query mySitesQuery {`

but not

``query my_sitesQuery {`

That said:

yarn rw g cell MySites yarn rw g cell mySites

generates

export const QUERY = gql`
  query MySitesQuery {
    mySites {
      id
    }
  }
`

Is there a preferred case?

I noticed that in the GraphQL documentation the example is PascalCase:

query HeroNameAndFriends {
  hero {
    name
    friends {
      name
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dthyressoncommented, Jul 23, 2020

@peterp Happy to!

0reactions
dthyressoncommented, Jul 23, 2020

Right because, usually your component name will not be pascal cased:

  const outputComponentName =
    componentName || pascalcase(paramCase(name)) + suffix
Read more comments on GitHub >

github_iconTop Results From Across the Web

T4 FieldName in camelCase without Underscore?
How can I generate a field name without the '_' character? Also, where is the documentation for T4? I'm finding plenty of resources...
Read more >
What do you think about 'Camel case' vs. 'Underscore' naming ...
One disadvantage of using camel case names is that in some cases of ... that underscores are actually not bad, and the camelCase...
Read more >
Zalando RESTful API and Event Guidelines
SHOULD not use /api as base path; MUST pluralize resource names ... limit number of sub-resource levels; MUST use snake_case (never camelCase) for...
Read more >
(PDF) To camelcase or under-score - ResearchGate
boxes have essentially no effect on reading times or on the ... fier style (the use of underscores or camel casing) affects the....
Read more >
10 Best Practices for Naming REST API Endpoints
When I think about this, it is more like names that use common sense. Try to position yourself as the consumer. As someone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found