Gratis å bruke, uten konto

GraphQL-formaterer

Lim inn et GraphQL-spørring eller en skjemadefinisjon for å formatere den i nettleseren. Den lokale parseren kan peke ut syntaksfeil. Den kjører aldri spørringer eller sender kilden til en server.

Lim inn en spørring, mutasjon, abonnement eller SDL-definisjon.

Kun lokal formatering. Maksimal inndata: 100,000 tegn. Ingen kjøring eller opplasting.

Hvordan formaterer jeg GraphQL på nettet?

Lim inn en spørring, mutasjon, abonnement eller skjemadefinisjon, og velg «Formater GraphQL». Den første formateringen laster den lokale formatereren. Kopier eller last ned resultatet når det er klart.

Veiledning

Slik bruker du GraphQL-formaterer

The GraphQL Formatter tidies a query, mutation, subscription or schema written in GraphQL. Paste the text, press the format button and get it back with neat indents and line breaks. It checks syntax only. It never runs your query, contacts an API or sends your text anywhere.

Slik gjør du

  1. Paste your GraphQL into the input box, or press Load example to fill it with a short sample query and type definition.
  2. Press Format GraphQL. The first time you press it, the page loads its formatter, so wait a moment before the result appears.
  3. Read the formatted text in the result box, then press Copy or Download .graphql. Press Clear to start again with new text.

Eksempler

The built-in sample

Du skriver inn
Verdi
query GetUser($id: ID!) { user(id: $id) { id name email } } type User { id: ID! name: String! email: String }
Du får
Verdi
{ me { id friends(first: 10) { name } } }

Each field goes on its own line and nested blocks are indented by two spaces. The blank line between the query and the type is kept.

Kjørt med verktøyets egen kode.

A short query with commas

Du skriver inn
Verdi
{ me { id, friends(first:10){ name } } }
Du får
Verdi
{ me { id friends(first: 10) { name } } }

The comma after id is dropped, a space is added after the colon in the argument and every selection moves to its own line. GraphQL treats commas as whitespace, so the meaning is the same.

Kjørt med verktøyets egen kode.

A missing closing brace

Du skriver inn
Verdi
query { user { name }
Du får
Verdi
GraphQL syntax error. Line 1, column 22.

The parser reaches the end of the text while it still expects a closing brace, so nothing is formatted. The message points to the spot where it gave up, which is at the end of your text.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Make a long one-line query readable before you paste it into a ticket or code review.
  • Check that a snippet of schema definition has no typing slips before you add it to a project.
  • Give a team the same layout for queries so that differences in a diff show real changes only.

Begrensninger

  • It checks GraphQL syntax and layout only. It does not fetch a schema, so a field that does not exist is not reported.
  • The input box stops at 100,000 characters, and empty text shows a message instead of a result.
  • The layout is fixed: two-space indents, lines wrapped at 80 characters and no tabs. There are no settings to change them.

Tips

  • Fix the first syntax error that the message points to, then format again, because later errors can be a result of the first one.
  • Keep comments that start with a hash sign inside the text. They stay in the output, so you can still explain your query.
  • Use the download button when you want a file ending in .graphql, and the copy button when you only need to paste it elsewhere.

Kilder

Vanlige spørsmål

How do I format GraphQL online?

Paste a query, mutation, subscription or schema into the box and press Format GraphQL. The formatted version appears in a second box, and you can copy it or save it as a .graphql file.

Does the tool run my query or call an API?

No. It reads the text with a local parser and writes it back with new spacing. Nothing is executed, and the page says that your source is not uploaded to a server.

Can it format schema definitions as well as queries?

Yes. Type definitions, inputs, enums and the other schema forms are accepted, along with queries, mutations and subscriptions. The sample on the page uses a query and a type together.

Will it tell me if my query matches my schema?

No. It has no copy of your schema and makes no network calls. It only reports places where the text breaks GraphQL grammar, such as a missing brace or a stray character.

Why does the first format take a moment?

The formatter is a separate file that loads only when you first press the button, so the page itself stays light. After it has loaded, later runs in the same visit start at once.

Can I change the indent size or line width?

No. The tool always uses two spaces and an 80-character line width. If your team uses other settings, run your own formatter with those settings and treat this page as a quick check.

Hvordan formaterer jeg GraphQL på nettet?

Lim inn en spørring, mutasjon, abonnement eller skjemadefinisjon, og velg «Formater GraphQL». Den første formateringen laster den lokale formatereren. Kopier eller last ned resultatet når det er klart.

Lastes GraphQL-kilden min opp eller kjøres den?

Nei. Formateringen kjøres i nettleseren når du starter den. Verktøyet kontakter ikke et GraphQL-API, utfører ikke operasjoner og laster ikke opp kilden. Inndata er begrenset til 100 000 tegn.

Kan jeg formatere GraphQL-skjemaer og SDL?

Ja. Parseren formaterer GraphQL-spørringer og skjemadefinisjonsspråk, inkludert typedefinisjoner.

Validerer dette spørringen mot et aktivt skjema?

Nei. Det kontrollerer bare GraphQL-syntaks og formatering. Det henter ikke et skjema eller kaller et API.

Sendes spørringen min til en GraphQL-server?

Nei. Ingenting kjøres eller lastes opp. Formatereren kjører lokalt etter at du trykker på formateringsknappen.