Configure Prettier option singleQuote to the default, false.
This commit is contained in:
parent
e3d91cb16b
commit
783873a6be
@ -1,4 +1,3 @@
|
||||
{
|
||||
"proseWrap": "never",
|
||||
"singleQuote": true
|
||||
"proseWrap": "never"
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
{
|
||||
"proseWrap": "never",
|
||||
"singleQuote": true
|
||||
"proseWrap": "never"
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
export default new URL('../uploads/', import.meta.url);
|
||||
export default new URL("../uploads/", import.meta.url);
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql';
|
||||
import UPLOAD_DIRECTORY_URL from '../config/UPLOAD_DIRECTORY_URL.mjs';
|
||||
import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from "graphql";
|
||||
import UPLOAD_DIRECTORY_URL from "../config/UPLOAD_DIRECTORY_URL.mjs";
|
||||
|
||||
export default new GraphQLObjectType({
|
||||
name: 'File',
|
||||
description: 'A stored file.',
|
||||
name: "File",
|
||||
description: "A stored file.",
|
||||
fields: () => ({
|
||||
id: {
|
||||
description: 'Unique ID.',
|
||||
description: "Unique ID.",
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
resolve: (storedFileName) => storedFileName,
|
||||
},
|
||||
name: {
|
||||
description: 'File name.',
|
||||
description: "File name.",
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
resolve: (storedFileName) => storedFileName,
|
||||
},
|
||||
url: {
|
||||
description: 'File URL.',
|
||||
description: "File URL.",
|
||||
type: new GraphQLNonNull(GraphQLString),
|
||||
resolve: (storedFileName) =>
|
||||
new URL(storedFileName, UPLOAD_DIRECTORY_URL),
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
||||
import GraphQLUpload from 'graphql-upload/public/GraphQLUpload.js';
|
||||
import storeUpload from '../storeUpload.mjs';
|
||||
import FileType from './FileType.mjs';
|
||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from "graphql";
|
||||
import GraphQLUpload from "graphql-upload/public/GraphQLUpload.js";
|
||||
import storeUpload from "../storeUpload.mjs";
|
||||
import FileType from "./FileType.mjs";
|
||||
|
||||
export default new GraphQLObjectType({
|
||||
name: 'Mutation',
|
||||
name: "Mutation",
|
||||
fields: () => ({
|
||||
singleUpload: {
|
||||
description: 'Stores a single file.',
|
||||
description: "Stores a single file.",
|
||||
type: new GraphQLNonNull(FileType),
|
||||
args: {
|
||||
file: {
|
||||
description: 'File to store.',
|
||||
description: "File to store.",
|
||||
type: new GraphQLNonNull(GraphQLUpload),
|
||||
},
|
||||
},
|
||||
resolve: (parent, { file }) => storeUpload(file),
|
||||
},
|
||||
multipleUpload: {
|
||||
description: 'Stores multiple files.',
|
||||
description: "Stores multiple files.",
|
||||
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(FileType))),
|
||||
args: {
|
||||
files: {
|
||||
description: 'Files to store.',
|
||||
description: "Files to store.",
|
||||
type: new GraphQLNonNull(
|
||||
new GraphQLList(new GraphQLNonNull(GraphQLUpload))
|
||||
),
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import fs from 'fs';
|
||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
||||
import UPLOAD_DIRECTORY_URL from '../config/UPLOAD_DIRECTORY_URL.mjs';
|
||||
import FileType from './FileType.mjs';
|
||||
import fs from "fs";
|
||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from "graphql";
|
||||
import UPLOAD_DIRECTORY_URL from "../config/UPLOAD_DIRECTORY_URL.mjs";
|
||||
import FileType from "./FileType.mjs";
|
||||
|
||||
export default new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
name: "Query",
|
||||
fields: () => ({
|
||||
uploads: {
|
||||
description: 'All stored files.',
|
||||
description: "All stored files.",
|
||||
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(FileType))),
|
||||
resolve: () => fs.promises.readdir(UPLOAD_DIRECTORY_URL),
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
import MutationType from './MutationType.mjs';
|
||||
import QueryType from './QueryType.mjs';
|
||||
import { GraphQLSchema } from "graphql";
|
||||
import MutationType from "./MutationType.mjs";
|
||||
import QueryType from "./QueryType.mjs";
|
||||
|
||||
export default new GraphQLSchema({
|
||||
query: QueryType,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { fileURLToPath } from 'url';
|
||||
import { ApolloServer } from 'apollo-server-koa';
|
||||
import graphqlUploadKoa from 'graphql-upload/public/graphqlUploadKoa.js';
|
||||
import Koa from 'koa';
|
||||
import makeDir from 'make-dir';
|
||||
import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs';
|
||||
import schema from './schema/index.mjs';
|
||||
import { fileURLToPath } from "url";
|
||||
import { ApolloServer } from "apollo-server-koa";
|
||||
import graphqlUploadKoa from "graphql-upload/public/graphqlUploadKoa.js";
|
||||
import Koa from "koa";
|
||||
import makeDir from "make-dir";
|
||||
import UPLOAD_DIRECTORY_URL from "./config/UPLOAD_DIRECTORY_URL.mjs";
|
||||
import schema from "./schema/index.mjs";
|
||||
|
||||
/**
|
||||
* Starts the API server.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { createWriteStream, unlink } from 'fs';
|
||||
import shortId from 'shortid';
|
||||
import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs';
|
||||
import { createWriteStream, unlink } from "fs";
|
||||
import shortId from "shortid";
|
||||
import UPLOAD_DIRECTORY_URL from "./config/UPLOAD_DIRECTORY_URL.mjs";
|
||||
|
||||
/**
|
||||
* Stores a GraphQL file upload in the filesystem.
|
||||
@ -19,11 +19,11 @@ export default async function storeUpload(upload) {
|
||||
const writeStream = createWriteStream(storedFileUrl);
|
||||
|
||||
// When the upload is fully written, resolve the promise.
|
||||
writeStream.on('finish', resolve);
|
||||
writeStream.on("finish", resolve);
|
||||
|
||||
// If there's an error writing the file, remove the partially written file
|
||||
// and reject the promise.
|
||||
writeStream.on('error', (error) => {
|
||||
writeStream.on("error", (error) => {
|
||||
unlink(storedFileUrl, () => {
|
||||
reject(error);
|
||||
});
|
||||
@ -32,7 +32,7 @@ export default async function storeUpload(upload) {
|
||||
// In Node.js <= v13, errors are not automatically propagated between piped
|
||||
// streams. If there is an error receiving the upload, destroy the write
|
||||
// stream with the corresponding error.
|
||||
stream.on('error', (error) => writeStream.destroy(error));
|
||||
stream.on("error", (error) => writeStream.destroy(error));
|
||||
|
||||
// Pipe the upload into the write stream.
|
||||
stream.pipe(writeStream);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
{
|
||||
"proseWrap": "never",
|
||||
"singleQuote": true
|
||||
"proseWrap": "never"
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import styles from './Header.module.css';
|
||||
import styles from "./Header.module.css";
|
||||
|
||||
export const Header = (props) => (
|
||||
<header {...props} className={styles.header} />
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import Head from 'next/head';
|
||||
import PropTypes from 'prop-types';
|
||||
import Head from "next/head";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
export const Page = ({ title, children }) => (
|
||||
<>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import styles from './Section.module.css';
|
||||
import styles from "./Section.module.css";
|
||||
|
||||
export const Section = (props) => (
|
||||
<section {...props} className={styles.section} />
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { gql, useApolloClient, useMutation } from '@apollo/client';
|
||||
import ButtonSubmit from 'device-agnostic-ui/ButtonSubmit.mjs';
|
||||
import Code from 'device-agnostic-ui/Code.mjs';
|
||||
import Fieldset from 'device-agnostic-ui/Fieldset.mjs';
|
||||
import Textbox from 'device-agnostic-ui/Textbox.mjs';
|
||||
import React from 'react';
|
||||
import { gql, useApolloClient, useMutation } from "@apollo/client";
|
||||
import ButtonSubmit from "device-agnostic-ui/ButtonSubmit.mjs";
|
||||
import Code from "device-agnostic-ui/Code.mjs";
|
||||
import Fieldset from "device-agnostic-ui/Fieldset.mjs";
|
||||
import Textbox from "device-agnostic-ui/Textbox.mjs";
|
||||
import React from "react";
|
||||
|
||||
const SINGLE_UPLOAD_MUTATION = gql`
|
||||
mutation singleUpload($file: Upload!) {
|
||||
@ -14,8 +14,8 @@ const SINGLE_UPLOAD_MUTATION = gql`
|
||||
`;
|
||||
|
||||
export function UploadBlob() {
|
||||
const [name, setName] = React.useState('');
|
||||
const [content, setContent] = React.useState('');
|
||||
const [name, setName] = React.useState("");
|
||||
const [content, setContent] = React.useState("");
|
||||
const [singleUploadMutation, { loading }] = useMutation(
|
||||
SINGLE_UPLOAD_MUTATION
|
||||
);
|
||||
@ -26,7 +26,7 @@ export function UploadBlob() {
|
||||
const onSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const file = new Blob([content], { type: 'text/plain' });
|
||||
const file = new Blob([content], { type: "text/plain" });
|
||||
file.name = `${name}.txt`;
|
||||
|
||||
singleUploadMutation({ variables: { file } }).then(() => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { gql, useApolloClient, useMutation } from '@apollo/client';
|
||||
import { gql, useApolloClient, useMutation } from "@apollo/client";
|
||||
|
||||
const SINGLE_UPLOAD_MUTATION = gql`
|
||||
mutation singleUpload($file: Upload!) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { gql, useApolloClient, useMutation } from '@apollo/client';
|
||||
import { gql, useApolloClient, useMutation } from "@apollo/client";
|
||||
|
||||
const MULTIPLE_UPLOAD_MUTATION = gql`
|
||||
mutation multipleUpload($files: [Upload!]!) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import Scroll from 'device-agnostic-ui/Scroll.mjs';
|
||||
import Table from 'device-agnostic-ui/Table.mjs';
|
||||
import { gql, useQuery } from "@apollo/client";
|
||||
import Scroll from "device-agnostic-ui/Scroll.mjs";
|
||||
import Table from "device-agnostic-ui/Table.mjs";
|
||||
|
||||
const UPLOADS_QUERY = gql`
|
||||
query uploads {
|
||||
|
||||
@ -3,8 +3,8 @@ module.exports = {
|
||||
API_URI: process.env.API_URI,
|
||||
},
|
||||
i18n: {
|
||||
locales: ['en-US'],
|
||||
defaultLocale: 'en-US',
|
||||
locales: ["en-US"],
|
||||
defaultLocale: "en-US",
|
||||
},
|
||||
reactStrictMode: true,
|
||||
};
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
import 'device-agnostic-ui/theme.css';
|
||||
import 'device-agnostic-ui/global.css';
|
||||
import 'device-agnostic-ui/Button.css';
|
||||
import 'device-agnostic-ui/ButtonSubmit.css';
|
||||
import 'device-agnostic-ui/Code.css';
|
||||
import 'device-agnostic-ui/Fieldset.css';
|
||||
import 'device-agnostic-ui/Heading.css';
|
||||
import 'device-agnostic-ui/Loading.css';
|
||||
import 'device-agnostic-ui/Margin.css';
|
||||
import 'device-agnostic-ui/Scroll.css';
|
||||
import 'device-agnostic-ui/Table.css';
|
||||
import 'device-agnostic-ui/Textbox.css';
|
||||
import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client';
|
||||
import { createUploadLink } from 'apollo-upload-client';
|
||||
import Head from 'next/head';
|
||||
import PropTypes from 'prop-types';
|
||||
import "device-agnostic-ui/theme.css";
|
||||
import "device-agnostic-ui/global.css";
|
||||
import "device-agnostic-ui/Button.css";
|
||||
import "device-agnostic-ui/ButtonSubmit.css";
|
||||
import "device-agnostic-ui/Code.css";
|
||||
import "device-agnostic-ui/Fieldset.css";
|
||||
import "device-agnostic-ui/Heading.css";
|
||||
import "device-agnostic-ui/Loading.css";
|
||||
import "device-agnostic-ui/Margin.css";
|
||||
import "device-agnostic-ui/Scroll.css";
|
||||
import "device-agnostic-ui/Table.css";
|
||||
import "device-agnostic-ui/Textbox.css";
|
||||
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";
|
||||
import { createUploadLink } from "apollo-upload-client";
|
||||
import Head from "next/head";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
const createApolloClient = (cache = {}) =>
|
||||
new ApolloClient({
|
||||
ssrMode: typeof window === 'undefined',
|
||||
ssrMode: typeof window === "undefined",
|
||||
cache: new InMemoryCache().restore(cache),
|
||||
link: createUploadLink({ uri: process.env.API_URI }),
|
||||
});
|
||||
@ -49,7 +49,7 @@ App.getInitialProps = async (context) => {
|
||||
if (context.ctx.req) {
|
||||
const apolloClient = createApolloClient();
|
||||
try {
|
||||
const { getDataFromTree } = await import('@apollo/client/react/ssr');
|
||||
const { getDataFromTree } = await import("@apollo/client/react/ssr");
|
||||
await getDataFromTree(
|
||||
<App
|
||||
{...props}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import Code from 'device-agnostic-ui/Code.mjs';
|
||||
import Heading from 'device-agnostic-ui/Heading.mjs';
|
||||
import Margin from 'device-agnostic-ui/Margin.mjs';
|
||||
import { Header } from '../components/Header';
|
||||
import { Page } from '../components/Page';
|
||||
import { Section } from '../components/Section';
|
||||
import { UploadBlob } from '../components/UploadBlob';
|
||||
import { UploadFile } from '../components/UploadFile';
|
||||
import { UploadFileList } from '../components/UploadFileList';
|
||||
import { Uploads } from '../components/Uploads';
|
||||
import Code from "device-agnostic-ui/Code.mjs";
|
||||
import Heading from "device-agnostic-ui/Heading.mjs";
|
||||
import Margin from "device-agnostic-ui/Margin.mjs";
|
||||
import { Header } from "../components/Header";
|
||||
import { Page } from "../components/Page";
|
||||
import { Section } from "../components/Section";
|
||||
import { UploadBlob } from "../components/UploadBlob";
|
||||
import { UploadFile } from "../components/UploadFile";
|
||||
import { UploadFileList } from "../components/UploadFileList";
|
||||
import { Uploads } from "../components/Uploads";
|
||||
|
||||
const IndexPage = () => (
|
||||
<Page title="Apollo upload examples">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user