Skip to content

Commit

Permalink
Switch to use stable SWAPI endpoint in examples (#10242)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddeee888 authored Jan 18, 2025
1 parent 35d9365 commit 05d9731
Show file tree
Hide file tree
Showing 33 changed files with 43 additions and 48 deletions.
2 changes: 1 addition & 1 deletion examples/react/apollo-client-swc-plugin/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx', '!src/gql/**/*'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/apollo-client-swc-plugin/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import App from './App';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

const client = new ApolloClient({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://graphql.org/graphql/',
cache: new InMemoryCache(),
});

Expand Down
2 changes: 1 addition & 1 deletion examples/react/apollo-client/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/apollo-client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import App from './App';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

const client = new ApolloClient({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://graphql.org/graphql/',
cache: new InMemoryCache(),
});

Expand Down
2 changes: 1 addition & 1 deletion examples/react/http-executor/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
Expand Down
4 changes: 2 additions & 2 deletions examples/react/http-executor/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Film from './Film';
import { graphql, DocumentType } from './gql';

const executor = buildHTTPExecutor({
endpoint: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
endpoint: 'https://graphql.org/graphql/',
});

const AllFilmsWithVariablesQuery = graphql(/* GraphQL */ `
Expand All @@ -21,7 +21,7 @@ const AllFilmsWithVariablesQuery = graphql(/* GraphQL */ `
`);

// we could also define a client:
// `const client = new GraphQLClient('https://swapi-graphql.netlify.app/.netlify/functions/index')`
// `const client = new GraphQLClient('https://graphql.org/graphql/')`
// and use:
// `client.request(allFilmsWithVariablesQueryDocument, { first: 10 })`

Expand Down
2 changes: 1 addition & 1 deletion examples/react/nextjs-swr/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['components/**/*.tsx', 'pages/**/*.tsx'],
generates: {
'./gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/nextjs-swr/hooks/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ASTNode, ExecutionResult, Kind, OperationDefinitionNode } from 'graphql
import useSWR from 'swr';

const executor = buildHTTPExecutor({
endpoint: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
endpoint: 'https://graphql.org/graphql/',
});

const isOperationDefinition = (def: ASTNode): def is OperationDefinitionNode => def.kind === Kind.OPERATION_DEFINITION;
Expand Down
2 changes: 1 addition & 1 deletion examples/react/tanstack-react-query/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx', '!src/gql/**/*'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/tanstack-react-query/src/use-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function useGraphQL<TResult, TVariables>(
variables,
] as const,
async ({ queryKey }) => {
return fetch('https://swapi-graphql.netlify.app/.netlify/functions/index', {
return fetch('https://graphql.org/graphql/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion examples/react/urql/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx', '!src/gql/**/*'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/urql/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import './main.css';
import App from './App';

const client = createClient({
url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
url: 'https://graphql.org/graphql/',
});

const root = ReactDOM.createRoot(document.getElementById('app') as HTMLElement);
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-esm/codegen.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/** @type {import("@graphql-codegen/cli").CodegenConfig} */
const config = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.ts'],
emitLegacyCommonJSImports: false,
generates: {
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-esm/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AllPeopleWithVariablesQueryDocument = graphql(/* GraphQL */ `
}
`);

const apiUrl = 'https://swapi-graphql.netlify.app/.netlify/functions/index';
const apiUrl = 'https://graphql.org/graphql/';

executeOperation(apiUrl, AllPeopleQueryDocument).then(res => {
if (res.errors) {
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-graphql-request/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.ts'],
generates: {
'./src/gql/': {
Expand Down
3 changes: 1 addition & 2 deletions examples/typescript-graphql-request/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { GraphQLClient } from 'graphql-request';
import { graphql } from './gql';
import { AllPeopleQueryQuery } from './gql/graphql';
Expand Down Expand Up @@ -33,7 +32,7 @@ const AllPeopleWithVariablesQueryDocument = graphql(/* GraphQL */ `
}
`);

const apiUrl = 'https://swapi-graphql.netlify.app/.netlify/functions/index';
const apiUrl = 'https://graphql.org/graphql/';

const client = new GraphQLClient(apiUrl);

Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-cts/codegen.cts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-cts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { graphql } from './gql';
import { ApolloClient, InMemoryCache, ApolloProvider, useQuery } from '@apollo/client';

const client = new ApolloClient({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://graphql.org/graphql/',
cache: new InMemoryCache(),
});

Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-mts/codegen.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-mts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { graphql } from './gql';
import { ApolloClient, InMemoryCache, ApolloProvider, useQuery } from '@apollo/client';

const client = new ApolloClient({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://graphql.org/graphql/',
cache: new InMemoryCache(),
});

Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-ts/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/vite-react-ts/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { graphql } from './gql';
import { ApolloClient, InMemoryCache, ApolloProvider, useQuery } from '@apollo/client';

const client = new ApolloClient({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://graphql.org/graphql/',
cache: new InMemoryCache(),
});

Expand Down
2 changes: 1 addition & 1 deletion examples/vue/apollo-composable/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.vue', '!src/gql/**/*'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/apollo-composable/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client/core';
import App from './App.vue';

const httpLink = new HttpLink({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://graphql.org/graphql/',
});

// Create the apollo client
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/urql/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.vue', '!src/gql/**/*'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/urql/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import App from './App.vue';
const app = createApp(App);

app.use(urql, {
url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
url: 'https://graphql.org/graphql/',
exchanges: [cacheExchange, fetchExchange],
});

Expand Down
2 changes: 1 addition & 1 deletion examples/vue/villus/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.vue', '!src/gql/**/*'],
generates: {
'./src/gql/': {
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/villus/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FilmItem from './components/FilmItem.vue';
import { computed } from 'vue';
useClient({
url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
url: 'https://graphql.org/graphql/',
});
const { data } = useQuery({
Expand Down
4 changes: 2 additions & 2 deletions packages/presets/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
Expand Down Expand Up @@ -614,7 +614,7 @@
import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
Expand Down
4 changes: 2 additions & 2 deletions packages/presets/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ClientPresetConfig = {
* @exampleMarkdown
* ```tsx
* const config = {
* schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
* schema: 'https://graphql.org/graphql/',
* documents: ['src/**\/*.tsx', '!src\/gql/**\/*'],
* generates: {
* './src/gql/': {
Expand All @@ -49,7 +49,7 @@ export type ClientPresetConfig = {
* @exampleMarkdown
* ```tsx
* const config = {
* schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
* schema: 'https://graphql.org/graphql/',
* documents: ['src/**\/*.tsx', '!src\/gql/**\/*'],
* generates: {
* './src/gql/': {
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/docs/guides/react-query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contents:
import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
ignoreNoDocuments: true,
generates: {
Expand Down Expand Up @@ -170,7 +170,7 @@ export async function execute<TResult, TVariables>(
query: TypedDocumentString<TResult, TVariables>,
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
) {
const response = await fetch('https://swapi-graphql.netlify.app/.netlify/functions/index', {
const response = await fetch('https://graphql.org/graphql/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
16 changes: 6 additions & 10 deletions website/src/pages/docs/guides/react-vue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Tabs, Callout } from '@theguild/components'

GraphQL Code Generator provides a unified way to get TypeScript types from GraphQL operations for [most modern GraphQL clients and frameworks](#appendix-ii-compatibility).

This guide is built using the [Star wars films demo API](https://swapi-graphql.netlify.app/.netlify/functions/index).
This guide is built using the [Star wars films demo API](https://graphql.org/graphql/).

We will build a simple GraphQL front-end app using the following Query to fetch the list of Star Wars films:

Expand Down Expand Up @@ -62,7 +62,7 @@ Then provide the corresponding framework-specific configuration:
import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.tsx'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
Expand All @@ -83,7 +83,7 @@ export default config
import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.vue'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
Expand Down Expand Up @@ -184,7 +184,7 @@ const allFilmsWithVariablesQueryDocument = graphql(/* GraphQL */ `
function App() {
// `data` is typed!
const { data } = useQuery(['films'], async () =>
request('https://swapi-graphql.netlify.app/.netlify/functions/index', allFilmsWithVariablesQueryDocument, {
request('https://graphql.org/graphql/', allFilmsWithVariablesQueryDocument, {
first: 10 // variables are typed too!
})
)
Expand Down Expand Up @@ -535,11 +535,7 @@ export function useGraphQL<TResult, TVariables>(
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
): UseQueryResult<TResult> {
return useQuery([(document.definitions[0] as any).name.value, variables], async ({ queryKey }) =>
request(
'https://swapi-graphql.netlify.app/.netlify/functions/index',
document,
queryKey[1] ? queryKey[1] : undefined
)
request('https://graphql.org/graphql/', document, queryKey[1] ? queryKey[1] : undefined)
)
}
```
Expand Down Expand Up @@ -623,7 +619,7 @@ export function useGraphQL<TResult, TVariables>(
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
): UseQueryResult<ExecutionResult<TResult>> {
return useQuery([(document.definitions[0] as any).name.value, variables], () =>
customFetcher('https://swapi-graphql.netlify.app/.netlify/functions/index', document, variables)
customFetcher('https://graphql.org/graphql/', document, variables)
)
}
```
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/docs/guides/vanilla-typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contents:
import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
schema: 'https://graphql.org/graphql/',
documents: ['src/**/*.ts'],
ignoreNoDocuments: true,
generates: {
Expand Down Expand Up @@ -187,7 +187,7 @@ export async function execute<TResult, TVariables>(
query: TypedDocumentString<TResult, TVariables>,
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
) {
const response = await fetch('https://swapi-graphql.netlify.app/.netlify/functions/index', {
const response = await fetch('https://graphql.org/graphql/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down

0 comments on commit 05d9731

Please sign in to comment.