Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] [reference] Introduce Query Params #1579

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

harshithpabbati
Copy link
Contributor

This PR introduces Query Params

Todo

  • Pass query, variables through URI
  • Parse through the URI to get query, variables

@acao acao changed the base branch from master to main June 19, 2020 14:37
);

React.useEffect(() => {
updateQueryStringURL(state.queryStringParams);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing the parsing here, the parsing should happen in the reducer. just to keep all the processing happening in one place, on a per-action basis

@harshithpabbati
Copy link
Contributor Author

Also, @acao looks like main branch is not configured in netlify for preview URL's

@acao
Copy link
Member

acao commented Jun 20, 2020

@harshithpabbati fixed! this was supposed to be changed programatically in netlify.toml but it didn't seem to work. should be good now!

@harshithpabbati harshithpabbati force-pushed the feat/query-params branch 2 times, most recently from 0b790ea to eda6d26 Compare June 21, 2020 12:13
@@ -89,6 +92,7 @@ export function VariableEditor(props: VariableEditorProps) {
if (!ignoreChangeEvent) {
cachedValueRef.current = editor.getValue();
session.changeVariables(cachedValueRef.current);
browser.changeQueryStringParams('variables', cachedValueRef.current);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly what i was hoping for! excellent work @harshithpabbati !

@acao acao force-pushed the main branch 6 times, most recently from 4fa9ca3 to 1c11938 Compare February 1, 2021 18:22
@acao
Copy link
Member

acao commented Feb 1, 2021

@harshithpabbati idea: make this a utility in @graphiql/toolkit, that only graphql cdn.ts imports that is implemented using props somehow

@harshithpabbati
Copy link
Contributor Author

sure, will do 👍

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2021

⚠️ No Changeset found

Latest commit: b00c488

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov
Copy link

codecov bot commented Feb 5, 2021

Codecov Report

Merging #1579 (4fefbb7) into main (9223806) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1579   +/-   ##
=======================================
  Coverage   65.66%   65.66%           
=======================================
  Files          85       85           
  Lines        5115     5115           
  Branches     1624     1624           
=======================================
  Hits         3359     3359           
  Misses       1752     1752           
  Partials        4        4           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9223806...2774415. Read the comment docs.

@acao
Copy link
Member

acao commented Feb 6, 2021

@harshithpabbati thanks for implementing this in the RFC as well!

imolorhe and others added 7 commits February 9, 2021 08:59
* Migrated codemirror-graphql to typescript

* Migrated codemirror-graphql tests to typescript

* Cleaned up codemirror-graphql package.json
set build output to root (to align with current behavior)

* ignore generated __tests__ folder from eslint

* Updated codemirror typing

* Updated codemirror typing

* Updated ci-e2e script

* Exclude babel and jest config from npm files
Co-authored-by: Samuel <samuelimolo4real@gmail.com>
Co-authored-by: Rikki <rikki.schulte@gmail.com>
variables: parseQueryStringURL(window.location.search).variables,
operationName: parseQueryStringURL(window.location.search).operationName,
},
queryStringParamsURL: '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why we need to have both queryStringParams and queryStringParamsURL. If I understand it correctly, they both contain the same data, just formatted differently.

@@ -89,6 +92,7 @@ export function VariableEditor(props: VariableEditorProps) {
if (!ignoreChangeEvent) {
cachedValueRef.current = editor.getValue();
session.changeVariables(cachedValueRef.current);
browser.changeQueryStringParams('variables', cachedValueRef.current);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acao question: should the browser context util be separated from the session context util? From what I can see, we seem to also be setting session whenever we are changing the query string. So perhaps the session context util can simply update the browser context as well? Or is there another reason why we have them separate that I'm not aware of?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session here refers to the current tab, incidentally haha. Maybe EditorSession would be more explicit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way, all of this will be replaced. excellent points to consider in the next state management iteration.

@acao
Copy link
Member

acao commented Jul 28, 2022

@thomasheyenbrock @jonathanawesome I think this one is really important to address in 2.0.0!

Users have long requested a configurable and safe way to handle query params, but most in their implementations are left up to them. The expectation of query, variables and a few other safe parameters (http request url is safe now) to come with GraphiQL is quite standard now, but it's not actually implemented!

@acao acao changed the title feat: [RFC] Introduce Query Params [RFC] [reference] Introduce Query Params Jul 30, 2022
@acao acao added graphiql and removed graphiql@2 labels Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants